self.assertNotEqual(collector.configuration["harpoon"], collector2.configuration["harpoon"]) self.assertEqual(collector.configuration["harpoon"].chosen_image, "blah") self.assertEqual(collector2.configuration["harpoon"].chosen_image, "other") describe "prepare": it "adds some items to the configuration from the args_dict": bash = "bash command" extra = "extra commands after the --" command = "Command command" args_dict = {"harpoon": {}} configuration = {"images": {"blah": {"commands": "FROM ubuntu:14.04"}}} with self.a_temp_file(json.dumps(configuration)) as filename: collector = Collector() raw_config = collector.collect_configuration(filename, args_dict) for thing in ("configuration", "$@", "bash", "command", "harpoon"): assert thing not in raw_config, "expected {0} to not be in configuration".format(thing) args_dict = {"harpoon": {"extra": extra}, "bash": bash, "command": command, "assume_role": None} collector.prepare(filename, args_dict) # Done by option_merge self.assertEqual(collector.configuration["getpass"], getpass) self.assertEqual(collector.configuration["args_dict"].as_dict(), args_dict) self.assertEqual(collector.configuration["collector"], collector) self.assertEqual(collector.configuration["config_root"], os.path.dirname(filename)) # Done by bespin self.assertEqual(collector.configuration["$@"], extra) self.assertEqual(collector.configuration["bash"], bash)
self.assertNotEqual(collector.configuration["harpoon"], collector2.configuration["harpoon"]) self.assertEqual(collector.configuration["harpoon"].chosen_image, "blah") self.assertEqual(collector2.configuration["harpoon"].chosen_image, "other") describe "prepare": it "adds some items to the configuration from the args_dict": bash = "bash command" extra = "extra commands after the --" command = "Command command" args_dict = {"harpoon": {}} configuration = {"images": {"blah": {"commands": "FROM ubuntu:14.04"}}} with self.a_temp_file(json.dumps(configuration)) as filename: collector = Collector() raw_config = collector.collect_configuration(filename, args_dict) for thing in ("configuration", "$@", "bash", "command", "harpoon"): assert thing not in raw_config, "expected {0} to not be in configuration".format(thing) args_dict = {"harpoon": {"extra": extra}, "bash": bash, "command": command, "assume_role": None} collector.prepare(filename, args_dict) # Done by option_merge self.assertEqual(collector.configuration["getpass"], getpass) self.assertEqual(collector.configuration["args_dict"].as_dict(), args_dict) self.assertEqual(collector.configuration["collector"], collector) self.assertEqual(collector.configuration["config_root"], os.path.dirname(filename)) # Done by bespin self.assertEqual(collector.configuration["$@"], extra) self.assertEqual(collector.configuration["bash"], bash)
describe "prepare": it "complains if there is no images": configuration = {} with self.a_temp_file(json.dumps(configuration)) as filename: with self.fuzzyAssertRaisesError(Collector.BadConfigurationErrorKls, "Didn't find any images in the configuration"): Collector().prepare(filename, {}) it "adds some items to the configuration from the cli_args": bash = "bash command" extra = "extra commands after the --" command = "Command command" configuration = {"images": {"blah": {"commands": "FROM ubuntu:14.04"}}} with self.a_temp_file(json.dumps(configuration)) as filename: collector = Collector() raw_config = collector.collect_configuration(filename) for thing in ("configuration", "$@", "bash", "command", "harpoon", "collector", "getpass", "cli_args"): assert thing not in raw_config, "expected {0} to not be in configuration".format(thing) cli_args = {"harpoon": {"extra": extra}, "bash": bash, "command": command} collector.prepare(filename, cli_args) # Done by option_merge self.assertEqual(collector.configuration["getpass"], getpass) self.assertEqual(collector.configuration["cli_args"].as_dict(), cli_args) self.assertEqual(collector.configuration["collector"], collector) self.assertEqual(collector.configuration["config_root"], os.path.dirname(filename)) # Done by bespin self.assertEqual(collector.configuration["$@"], extra) self.assertEqual(collector.configuration["bash"], bash)