def test_config_rows_appear_the_same_for_loaded_multi_line_review(self): c = ReviewConfiguration() rows = [ "123 -i hal/* \\", " -i platform/* \\", " -i manuals/*", "new -x hal/*" ] c.load(rows) self.assertEqual(str(c).split("\n"), rows)
def test_error_for_loading_invalid_review_row(self): c = ReviewConfiguration() with self.assertRaisesRegexp(ExecutionError, "invalid config format: row 1"): c.load(["invalid -i hal/*"]) with self.assertRaisesRegexp(ExecutionError, "invalid config format: row 4"): c.load([ "123 -i hal/* \\", " -i platform/* \\", " -i manuals/*", "invalid -x hal/*" ])
def test_load(self): c = ReviewConfiguration() c.load(["123 -i hal/*", "new -x hal/*"]) cl = tuple(c) self.assertEqual(cl[0].review_id, "123") self.assertEqual(cl[0].filter_args, "-i hal/*") self.assertTrue(cl[1].review_id is None) self.assertEqual(cl[1].filter_args, "-x hal/*") self.assertEqual(str(c).split("\n"), ["123 -i hal/*", "new -x hal/*"]) self.assertEqual(len(cl), 2)
def test_load_with_review_spanning_multiple_lines(self): c = ReviewConfiguration() c.load([ "123 -i hal/* \\", " -i platform/* \\", " -i manuals/*", "new -x hal/*" ]) cl = tuple(c) self.assertEqual(len(cl), 2) self.assertEqual(cl[0].review_id, "123") self.assertEqual(cl[0].filter_args, "-i hal/* -i platform/* -i manuals/*") self.assertTrue(cl[1].review_id is None) self.assertEqual(cl[1].filter_args, "-x hal/*")
def test_load_option_uncommitted(self): c = ReviewConfiguration() c.load([]) self.assertEqual(c.get_option("uncommitted"), "false") c = ReviewConfiguration() c.load(["@uncommitted = false"]) self.assertEqual(c.get_option("uncommitted"), "false") c = ReviewConfiguration() c.load(["@uncommitted = true"]) self.assertEqual(c.get_option("uncommitted"), "true") c = ReviewConfiguration() c.load(["@uncommitted=true"]) self.assertEqual(c.get_option("uncommitted"), "true")
def test_load_with_empty_lines(self): c = ReviewConfiguration() c.load(["", "123 -i hal/*"]) self.assertEqual(len(tuple(c)), 1)
def test_load_with_comments(self): c = ReviewConfiguration() c.load(["# some comment...", "123 -i hal/*"]) self.assertEqual(len(tuple(c)), 1)
def test_config_rows_appear_in_same_order_as_loaded(self): c = ReviewConfiguration() rows = ["123 -i hal/*", "# comment", "456 -i platform/*"] c.load(rows) self.assertEqual(str(c).split("\n"), rows)
def test_error_for_loading_invalid_option_row(self): c = ReviewConfiguration() with self.assertRaisesRegexp(ExecutionError, "invalid config format"): c.load(["@uncommitted"])
def test_error_for_invalid_option_value(self): c = ReviewConfiguration() with self.assertRaisesRegexp(ExecutionError, "invalid option value"): c.load(["@uncommitted = 1"])
def test_error_for_loading_invalid_option(self): c = ReviewConfiguration() with self.assertRaisesRegexp(ExecutionError, "invalid config option"): c.load(["@does_not_exist = true"])