Example #1
0
 def test_get_unset_plugin_option_with_default(self):
     # this shows that even when we pass in a default to get,
     # we'll get the option's default as set in the plugin
     # this might not be what we really want
     p = MockPlugin({'sysroot': self.sysroot, 'policy': LinuxPolicy(init=InitSystem()),
                     'cmdlineopts': MockOptions()})
     self.assertEquals(p.get_option("opt", True), True)
Example #2
0
 def setUp(self):
     self.mp = MockPlugin({
         'cmdlineopts': MockOptions(),
         'policy': LinuxPolicy(init=InitSystem()),
         'sysroot': os.getcwd()
     })
     self.mp.archive = MockArchive()
Example #3
0
 def test_get_option_as_list_plugin_option_default(self):
     p = MockPlugin({
         'sysroot': self.sysroot,
         'policy': LinuxPolicy(init=InitSystem()),
         'cmdlineopts': MockOptions()
     })
     self.assertEquals(p.get_option_as_list("opt", default=[]), [])
Example #4
0
 def test_get_unset_plugin_option(self):
     p = MockPlugin({
         'sysroot': self.sysroot,
         'policy': LinuxPolicy(init=InitSystem()),
         'cmdlineopts': MockOptions()
     })
     self.assertEquals(p.get_option("opt"), 0)
Example #5
0
 def test_set_nonexistant_plugin_option(self):
     p = MockPlugin({
         'sysroot': self.sysroot,
         'policy': LinuxPolicy(init=InitSystem()),
         'cmdlineopts': MockOptions()
     })
     self.assertFalse(p.set_option("badopt", "testing"))
Example #6
0
 def test_plugin_no_descrip(self):
     p = MockPlugin({
         'sysroot': self.sysroot,
         'policy': LinuxPolicy(init=InitSystem()),
         'cmdlineopts': MockOptions()
     })
     self.assertEquals(p.get_description(), "<no description available>")
Example #7
0
 def test_plugin_set_name(self):
     p = NamedMockPlugin({
         'sysroot': self.sysroot,
         'policy': LinuxPolicy(init=InitSystem()),
         'cmdlineopts': MockOptions()
     })
     self.assertEquals(p.name(), "testing")
Example #8
0
 def test_get_option_as_list_plugin_option_not_list(self):
     p = MockPlugin({
         'sysroot': self.sysroot,
         'policy': LinuxPolicy(init=InitSystem()),
         'cmdlineopts': MockOptions()
     })
     p.set_option("opt", "testing")
     self.assertEquals(p.get_option_as_list("opt"), ['testing'])
Example #9
0
 def test_get_option_as_list_plugin_option(self):
     p = MockPlugin({
         'sysroot': self.sysroot,
         'policy': LinuxPolicy(init=InitSystem()),
         'cmdlineopts': MockOptions()
     })
     p.set_option("opt", "one,two,three")
     self.assertEquals(p.get_option_as_list("opt"), ['one', 'two', 'three'])
Example #10
0
 def setUp(self):
     self.mp = MockPlugin({
         'cmdlineopts': MockOptions(),
         'policy': LinuxPolicy(init=InitSystem(), probe_runtime=False),
         'sysroot': os.getcwd(),
         'devices': {}
     })
     self.mp.archive = MockArchive()
Example #11
0
 def test_postproc_default_on(self):
     p = PostprocMockPlugin({
         'cmdlineopts': MockOptions(),
         'sysroot': self.sysroot,
         'policy': LinuxPolicy(init=InitSystem())
     })
     p.postproc()
     self.assertTrue(p.did_postproc)
Example #12
0
 def test_get_unset_plugin_option(self):
     p = MockPlugin({
         'sysroot': self.sysroot,
         'policy': LinuxPolicy(init=InitSystem(), probe_runtime=False),
         'cmdlineopts': MockOptions(),
         'devices': {}
     })
     self.assertEquals(p.get_option("opt"), 0)
Example #13
0
 def test_plugin_default_name(self):
     p = MockPlugin({
         'sysroot': self.sysroot,
         'policy': LinuxPolicy(init=InitSystem(), probe_runtime=False),
         'cmdlineopts': MockOptions(),
         'devices': {}
     })
     self.assertEquals(p.name(), "mockplugin")
Example #14
0
 def test_plugin_no_descrip(self):
     p = NamedMockPlugin({
         'sysroot': self.sysroot,
         'policy': LinuxPolicy(init=InitSystem(), probe_runtime=False),
         'cmdlineopts': MockOptions(),
         'devices': {}
     })
     self.assertEquals(p.get_description(), "This plugin has a description.")
Example #15
0
 def test_copy_dir_forbidden_path(self):
     p = ForbiddenMockPlugin({
         'cmdlineopts': MockOptions(),
         'sysroot': self.sysroot,
         'policy': LinuxPolicy(init=InitSystem())
     })
     p.archive = MockArchive()
     p.setup()
     p.collect()
     self.assertEquals(p.archive.m, {})
Example #16
0
 def test_get_unset_plugin_option_with_default_not_none(self):
     # this shows that even when we pass in a default to get,
     # if the plugin default is not None
     # we'll get the option's default as set in the plugin
     # this might not be what we really want
     p = MockPlugin({
         'sysroot': self.sysroot,
         'policy': LinuxPolicy(init=InitSystem(), probe_runtime=False),
         'cmdlineopts': MockOptions(),
         'devices': {}
     })
     self.assertEquals(p.get_option("opt2", True), False)
Example #17
0
 def setUp(self):
     self.commons = {
         'sysroot': '/',
         'policy': LinuxPolicy(init=InitSystem()),
         'cmdlineopts': MockOptions()
     }
     self.plugin = Plugin(self.commons)
     self.plugin.opt_names = ['baz', 'empty', 'test_option']
     self.plugin.opt_parms = [{
         'enabled': False
     }, {
         'enabled': None
     }, {
         'enabled': 'foobar'
     }]
Example #18
0
 def determine_host_policy(self):
     """Attempts to identify the host installation against supported
     distributions
     """
     if self.local:
         self.log_info("using local policy %s"
                       % self.commons['policy'].distro)
         return self.commons['policy']
     host = load(cache={}, sysroot=self.opts.sysroot, init=InitSystem(),
                 probe_runtime=False, remote_exec=self.ssh_cmd,
                 remote_check=self.read_file('/etc/os-release'))
     if host:
         self.log_info("loaded policy %s for host" % host.distro)
         return host
     self.log_error('Unable to determine host installation. Ignoring node')
     raise UnsupportedHostException