27
30
gapmi = distros._get_arch_package_mirror_info # pylint: disable=W0212
30
class TestGenericDistro(MockerTestCase):
33
class TestGenericDistro(helpers.FilesystemMockingTestCase):
32
35
def return_first(self, mlist):
52
55
# Make a temp directoy for tests to use.
53
56
self.tmp = self.makeDir()
58
def test_sudoers_ensure_new(self):
59
cls = distros.fetch("ubuntu")
60
d = cls("ubuntu", {}, None)
61
self.patchOS(self.tmp)
62
self.patchUtils(self.tmp)
63
d.ensure_sudo_dir("/b")
64
contents = util.load_file("/etc/sudoers")
65
self.assertIn("includedir /b", contents)
66
self.assertTrue(os.path.isdir("/b"))
68
def test_sudoers_ensure_append(self):
69
cls = distros.fetch("ubuntu")
70
d = cls("ubuntu", {}, None)
71
self.patchOS(self.tmp)
72
self.patchUtils(self.tmp)
73
util.write_file("/etc/sudoers", "josh, josh\n")
74
d.ensure_sudo_dir("/b")
75
contents = util.load_file("/etc/sudoers")
76
self.assertIn("includedir /b", contents)
77
self.assertTrue(os.path.isdir("/b"))
78
self.assertIn("josh", contents)
79
self.assertEquals(2, contents.count("josh"))
55
81
def test_arch_package_mirror_info_unknown(self):
56
82
"""for an unknown arch, we should get back that with arch 'default'."""
57
83
arch_mirrors = gapmi(package_mirrors, arch="unknown")