checks: Update tests to not require python modules

This way the tests are more independent of the system they are running
on.

Merges: #447
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2016-10-25 15:25:56 +02:00
parent 933c2608cd
commit f4cd25450b

View File

@ -38,6 +38,7 @@ class CheckDependenciesTestCase(unittest.TestCase):
machine.return_value = 'x86_64' machine.return_value = 'x86_64'
with mock.patch('os.path.exists') as exists: with mock.patch('os.path.exists') as exists:
exists.side_effect = self.dont_find([]) exists.side_effect = self.dont_find([])
with mock.patch('__builtin__.__import__'):
result = checks.check({}) result = checks.check({})
self.assertEqual('', out.getvalue()) self.assertEqual('', out.getvalue())
@ -53,6 +54,7 @@ class CheckDependenciesTestCase(unittest.TestCase):
machine.return_value = 'x86_64' machine.return_value = 'x86_64'
with mock.patch('os.path.exists') as exists: with mock.patch('os.path.exists') as exists:
exists.side_effect = self.dont_find(['/usr/bin/jigdo-lite']) exists.side_effect = self.dont_find(['/usr/bin/jigdo-lite'])
with mock.patch('__builtin__.__import__'):
result = checks.check(conf) result = checks.check(conf)
self.assertEqual('', out.getvalue()) self.assertEqual('', out.getvalue())
@ -68,6 +70,7 @@ class CheckDependenciesTestCase(unittest.TestCase):
with mock.patch('sys.stdout', new_callable=StringIO.StringIO) as out: with mock.patch('sys.stdout', new_callable=StringIO.StringIO) as out:
with mock.patch('os.path.exists') as exists: with mock.patch('os.path.exists') as exists:
exists.side_effect = self.dont_find(['/usr/bin/isohybrid']) exists.side_effect = self.dont_find(['/usr/bin/isohybrid'])
with mock.patch('__builtin__.__import__'):
result = checks.check(conf) result = checks.check(conf)
self.assertEqual('', out.getvalue()) self.assertEqual('', out.getvalue())
@ -82,6 +85,7 @@ class CheckDependenciesTestCase(unittest.TestCase):
with mock.patch('sys.stdout', new_callable=StringIO.StringIO) as out: with mock.patch('sys.stdout', new_callable=StringIO.StringIO) as out:
with mock.patch('os.path.exists') as exists: with mock.patch('os.path.exists') as exists:
exists.side_effect = self.dont_find(['/usr/bin/isohybrid']) exists.side_effect = self.dont_find(['/usr/bin/isohybrid'])
with mock.patch('__builtin__.__import__'):
result = checks.check(conf) result = checks.check(conf)
self.assertEqual('', out.getvalue()) self.assertEqual('', out.getvalue())
@ -99,6 +103,7 @@ class CheckDependenciesTestCase(unittest.TestCase):
machine.return_value = 'armhfp' machine.return_value = 'armhfp'
with mock.patch('os.path.exists') as exists: with mock.patch('os.path.exists') as exists:
exists.side_effect = self.dont_find(['/usr/bin/isohybrid']) exists.side_effect = self.dont_find(['/usr/bin/isohybrid'])
with mock.patch('__builtin__.__import__'):
result = checks.check(conf) result = checks.check(conf)
self.assertRegexpMatches(out.getvalue(), r'^Not checking.*Expect failures.*$') self.assertRegexpMatches(out.getvalue(), r'^Not checking.*Expect failures.*$')
@ -112,6 +117,7 @@ class CheckDependenciesTestCase(unittest.TestCase):
with mock.patch('sys.stdout', new_callable=StringIO.StringIO) as out: with mock.patch('sys.stdout', new_callable=StringIO.StringIO) as out:
with mock.patch('os.path.exists') as exists: with mock.patch('os.path.exists') as exists:
exists.side_effect = self.dont_find(['/usr/bin/isohybrid']) exists.side_effect = self.dont_find(['/usr/bin/isohybrid'])
with mock.patch('__builtin__.__import__'):
result = checks.check(conf) result = checks.check(conf)
self.assertEqual('', out.getvalue()) self.assertEqual('', out.getvalue())
@ -125,6 +131,7 @@ class CheckDependenciesTestCase(unittest.TestCase):
with mock.patch('sys.stdout', new_callable=StringIO.StringIO) as out: with mock.patch('sys.stdout', new_callable=StringIO.StringIO) as out:
with mock.patch('os.path.exists') as exists: with mock.patch('os.path.exists') as exists:
exists.side_effect = self.dont_find(['/usr/bin/genisoimage']) exists.side_effect = self.dont_find(['/usr/bin/genisoimage'])
with mock.patch('__builtin__.__import__'):
result = checks.check(conf) result = checks.check(conf)
self.assertEqual('', out.getvalue()) self.assertEqual('', out.getvalue())