--- /dev/null
+#!/usr/bin/python
+
+# Fake dpkg-query python script to emulate output for test usage
+
+# Python3-compatible print() function
+from __future__ import print_function
+
+import sys
+import os
+import random
+
+if len(sys.argv) < 5:
+ sys.exit("Not enough arguments.")
+
+if sys.argv[1] != '-f' or \
+ sys.argv[2] != '${Version} ${Provides}\n' or \
+ sys.argv[3] != '-W':
+ sys.exit("Wrong input arguments.")
+
+if os.environ.get('TEST_DPKG_QUERY_NONE') == '1':
+ for package in sys.argv[4::]:
+ print('No packages found matching ' + package + '.',file=sys.stderr)
+
+if os.environ.get('TEST_DPKG_QUERY_ALL') == '1':
+ arch = 'TESTarch'
+ for package in sys.argv[4::]:
+ vers_sep = random.choice('-+~')
+ vers = '9.8' + vers_sep + 'Debian7ubuntu6'
+ print(vers + ' ' + package + '-' + arch + ', ' + package + '-noarch')
[elem for elem in in_versions if int(float(elem)*10) <= int(float(test_v)*10)],
assert_text)
- @unittest.skip('Test not implemented.')
def test_check_modules_installed(self):
- raise NotImplementedError()
+ # Test that when no packages are available, then we get nothing out.
+ os.environ['TEST_DPKG_QUERY_NONE'] = '1'
+ self.assertEqual(lr.check_modules_installed(),[])
+ os.environ.pop('TEST_DPKG_QUERY_NONE')
+
+ # Test with all packages available.
+ supposed_output = [pkg[4::] + '-9.8-TESTarch' for pkg in lr.PACKAGES.split(' ')]
+ supposed_output += [pkg[4::] + '-9.8-noarch' for pkg in lr.PACKAGES.split(' ')]
+ supposed_output.sort()
+ os.environ['TEST_DPKG_QUERY_ALL'] = '1'
+ self.assertEqual(sorted(lr.check_modules_installed()),supposed_output)
def test_parse_policy_line(self):
release_line = ''