summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDidier Raboud <odyx@debian.org>2012-05-22 11:48:32 +0200
committerDidier Raboud <odyx@debian.org>2012-05-22 11:48:32 +0200
commitae335d70e4346653b4ab81b27debceb0a5a0f88c (patch)
tree0922e40d51fe929339be1c2cec5613e289dc32cc /test
parentc2b1ce63e5ded1ca275bc5eb3f50ea98c521d64d (diff)
PyUT: Implement test for lsb_release.parse_apt_policy.
Diffstat (limited to 'test')
-rwxr-xr-xtest/apt-cache11
-rw-r--r--test/test_lsb_release.py16
2 files changed, 25 insertions, 2 deletions
diff --git a/test/apt-cache b/test/apt-cache
index f6cc88f..17c7c5e 100755
--- a/test/apt-cache
+++ b/test/apt-cache
@@ -6,6 +6,7 @@
from __future__ import print_function
import sys
+import os
if len(sys.argv) <= 1 or sys.argv[1] != 'policy':
sys.exit("Shall only be run with exactly one argument: 'policy'")
@@ -13,3 +14,13 @@ if len(sys.argv) <= 1 or sys.argv[1] != 'policy':
print("Package files:")
print(" 100 /var/lib/dpkg/status")
print(" release a=now")
+
+if os.environ.get('TEST_APT_CACHE1') == '132':
+ print(' 132 http://Mirror_is_not_read/folder-either-debian/ sid/main arch Packages')
+ print(' release o=oRigIn,a=SuiTe,n=codename-not-read,l=lABel,c=C0mp0nent')
+ print(' origin Mirror-is-not-read')
+
+if os.environ.get('TEST_APT_CACHE2') == '35':
+ print(' 35 http://MirRor_is_not_read/folder-either-debian/ sid/main arch Packages')
+ print(' release o=0RigIn,a=5uiTe,n=codename-not-read,l=1ABel,c=C03p0nent')
+ print(' origin MirRor-is-not-read')
diff --git a/test/test_lsb_release.py b/test/test_lsb_release.py
index 0292f4a..6c9c3a2 100644
--- a/test/test_lsb_release.py
+++ b/test/test_lsb_release.py
@@ -6,6 +6,8 @@ import lsb_release as lr
import random
import string
+import os
+
def rnd_string(min_l,max_l):
return ''.join( [random.choice(string.letters) for i in xrange(random.randint(min_l,max_l))])
@@ -102,9 +104,19 @@ class TestLSBRelease(unittest.TestCase):
supposed_output,
'compare_release(' + x[1]['suite'] + ',' + y[1]['suite'] + ') =? ' + str(supposed_output))
- @unittest.skip('Test not implemented.')
def test_parse_apt_policy(self):
- raise NotImplementedError()
+ # Test almost-empty apt-cache policy
+ supposed_output = [(100, {'suite': 'now'})]
+ self.assertEqual(lr.parse_apt_policy(),supposed_output)
+ # Add one fake entry
+ os.environ['TEST_APT_CACHE1'] = '132'
+ supposed_output.append((132, {'origin': 'oRigIn', 'suite': 'SuiTe', 'component': 'C0mp0nent', 'label': 'lABel'}))
+ self.assertEqual(lr.parse_apt_policy(),supposed_output)
+ # Add a second fake entry, unordered
+ os.environ['TEST_APT_CACHE2'] = '35'
+ supposed_output.append((35, {'origin': '0RigIn', 'suite': '5uiTe', 'component': 'C03p0nent', 'label': '1ABel'}))
+ self.assertEqual(lr.parse_apt_policy(),supposed_output)
+
@unittest.skip('Test not implemented.')
def test_guess_release_from_apt(self):
raise NotImplementedError()