def test_multiple_dash_ds(self): args = parse_args( self.config, ["-h", "host", "-d", "component", "-d", "component2"]) canonical = construct_canonical_commandline(self.config, args) self.assertEqual( "-h host --parallel=5 --timeout=60 -d component component2", canonical)
def test_profiles_arg(self): args = ["foo", "-h", "a", "-c", "test"] profile_info, args = self.profile_parser.parse_known_args(args=args) full_args = parse_args(self.config, args) self.assertEqual(profile_info.profile, "foo") self.assertEqual(cmdline(full_args.commands), [["test"]])
def test_multi_restart(self): args = parse_args(self.config, ["-h", "a", "-r", "all", "-r", "more"]) self.assertEqual(cmdline(args.commands), [["restart", "all"], ["restart", "more"]])
def test_dangerously_fast_on(self): args = parse_args(self.config, ["-h", "a", "--dangerously-fast"]) self.assertTrue(args.dangerously_fast)
def test_verbose_flagged_long(self): args = parse_args(self.config, ["-h", "a", "--verbose"]) self.assertTrue(args.verbose_logging)
def test_harold_disabled(self): args = parse_args(self.config, ["-h", "a", "--really-no-harold"]) self.assertFalse(args.notify_harold)
def test_list_flagged(self): args = parse_args(self.config, ["-h", "a", "--list"]) self.assertTrue(args.list_hosts)
def test_sleeptime_override(self): args = parse_args(self.config, ["-h", "a", "--sleeptime", "1"]) self.assertEqual(args.sleeptime, 1)
def test_parallel_override(self): args = parse_args(self.config, ["-h", "a", "--parallel", "3"]) self.assertEqual(args.parallel, 3)
def test_no_harold(self): args = parse_args(self.config, ["-h", "host", "--really-no-harold"]) canonical = construct_canonical_commandline(self.config, args) self.assertEqual( "-h host --parallel=5 --timeout=60 --really-no-harold", canonical)
def test_sleeptime(self): args = parse_args(self.config, ["-h", "host", "--sleeptime", "5"]) canonical = construct_canonical_commandline(self.config, args) self.assertEqual("-h host --parallel=5 --sleeptime=5 --timeout=60", canonical)
def test_multiple_hosts(self): args = parse_args(self.config, ["-h", "host", "host2"]) canonical = construct_canonical_commandline(self.config, args) self.assertEqual("-h host host2 --parallel=5 --timeout=60", canonical)
def test_commands_together(self): args = parse_args(self.config, ["-h", "a", "-c", "test", "args", "-r", "all"]) self.assertEqual(cmdline(args.commands), [["test", "args"], ["restart", "all"]])
def test_command_with_args(self): args = parse_args(self.config, ["-h", "a", "-c", "test", "args"]) self.assertEqual(cmdline(args.commands), [["test", "args"]])
def test_no_commands(self): args = parse_args(self.config, ["-h", "a"]) self.assertEqual(cmdline(args.commands), [])
def test_multiple_host_lists(self): args = parse_args(self.config, ["-h", "a", "-h", "b"]) self.assertEqual(args.host_refs, ["a", "b"])
def test_parallel_default(self): args = parse_args(self.config, ["-h", "a"]) self.assertEqual(args.parallel, 5)
def test_no_args(self): with self.assertRaises(SystemExit): parse_args(self.config, [])
def test_sleeptime_default(self): args = parse_args(self.config, ["-h", "a"]) self.assertEqual(args.sleeptime, 2)
def test_multi_restart(self): args = parse_args(self.config, ["-h", "host", "-r", "com1", "-r", "com2"]) canonical = construct_canonical_commandline(self.config, args) self.assertEqual("-h host --parallel=5 --timeout=60 -r com1 -r com2", canonical)
def test_list_default(self): args = parse_args(self.config, ["-h", "a"]) self.assertFalse(args.list_hosts)
def test_command_with_args(self): args = parse_args(self.config, ["-h", "host", "-c", "cmd", "arg"]) canonical = construct_canonical_commandline(self.config, args) self.assertEqual("-h host --parallel=5 --timeout=60 -c cmd arg", canonical)
def test_harold_default(self): args = parse_args(self.config, ["-h", "a"]) self.assertTrue(args.notify_harold)
def test_multiple_commands(self): args = parse_args(self.config, ["-h", "host", "-c", "cmd1", "-c", "cmd2"]) canonical = construct_canonical_commandline(self.config, args) self.assertEqual("-h host --parallel=5 --timeout=60 -c cmd1 -c cmd2", canonical)
def test_verbose_default(self): args = parse_args(self.config, ["-h", "a"]) self.assertFalse(args.verbose_logging)
def test_verbose(self): args = parse_args(self.config, ["-h", "host", "-v"]) canonical = construct_canonical_commandline(self.config, args) self.assertEqual("-h host --parallel=5 --timeout=60 --verbose", canonical)
def test_dangerously_fast_default(self): args = parse_args(self.config, ["-h", "a"]) self.assertFalse(args.dangerously_fast)
def test_host_list(self): args = parse_args(self.config, ["-h", "a", "b", "c"]) self.assertEqual(args.host_refs, ["a", "b", "c"])
def test_empty_deploys(self): args = parse_args(self.config, ["-h", "a"]) self.assertEqual(args.components, [])
def test_multiple_deploys(self): args = parse_args(self.config, ["-h", "a", "-d", "comp", "-d", "comp2"]) self.assertEqual(args.components, ["comp", "comp2"])