Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_get_rocker_version(self):
v = get_rocker_version()
parts = v.split('.')
self.assertEqual(len(parts), 3)
for p in parts:
# Check that it can be cast to an int
i = int(p)
def plugin_load_parser_correctly(plugin):
"""A helper function to test that the plugins at least
register an option for their own name."""
parser = argparse.ArgumentParser(description='test_parser')
plugin.register_arguments(parser)
argument_name = name_to_argument(plugin.get_name())
for action in parser._actions:
option_strings = getattr(action, 'option_strings', [])
if argument_name in option_strings:
return True
return False
def test_name_to_argument(self):
self.assertEqual(name_to_argument('asdf'), '--asdf')
self.assertEqual(name_to_argument('as_df'), '--as-df')
self.assertEqual(name_to_argument('as-df'), '--as-df')
def test_name_to_argument(self):
self.assertEqual(name_to_argument('asdf'), '--asdf')
self.assertEqual(name_to_argument('as_df'), '--as-df')
self.assertEqual(name_to_argument('as-df'), '--as-df')
def test_name_to_argument(self):
self.assertEqual(name_to_argument('asdf'), '--asdf')
self.assertEqual(name_to_argument('as_df'), '--as-df')
self.assertEqual(name_to_argument('as-df'), '--as-df')
def test_run_before_build(self):
dig = DockerImageGenerator([], {}, 'ubuntu:bionic')
self.assertEqual(dig.run('true'), 1)
self.assertEqual(dig.build(), 0)
self.assertEqual(dig.run('true'), 0)
def test_device(self):
dig = DockerImageGenerator([], {}, 'ubuntu:bionic')
self.assertEqual(dig.build(), 0)
self.assertEqual(dig.run('true', devices=['/dev/random']), 0)
self.assertEqual(dig.run('true', devices=['/dev/does_not_exist']), 0)
def test_return_code_multiple_extensions(self):
plugins = list_plugins()
desired_plugins = ['home', 'user']
active_extensions = [e() for e in plugins.values() if e.get_name() in desired_plugins]
dig = DockerImageGenerator(active_extensions, {}, 'ubuntu:bionic')
self.assertEqual(dig.build(), 0)
self.assertEqual(dig.run('true'), 0)
self.assertEqual(dig.run('false'), 1)
def test_noexecute(self):
dig = DockerImageGenerator([], {}, 'ubuntu:bionic')
self.assertEqual(dig.build(), 0)
self.assertEqual(dig.run('true', noexecute=True), 0)
def test_return_code_no_extensions(self):
dig = DockerImageGenerator([], {}, 'ubuntu:bionic')
self.assertEqual(dig.build(), 0)
self.assertEqual(dig.run('true'), 0)
self.assertEqual(dig.run('false'), 1)