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'")
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')
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))])
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()