switch to having full_name/identifier instead of identifier/output_markdown_file
[utils.git] / src / budget_sync / test / test_config.py
index 6a40c18c30237abb11bd2a9e1c4114120b7d2646..d963b94c5bccdc9212e0dec4126431daedb98aaf 100644 (file)
@@ -4,6 +4,8 @@ from budget_sync.config import Config, ConfigParseError
 
 
 class TestConfig(unittest.TestCase):
+    maxDiff = None
+
     def test_config_parsing(self):
         def check_error(text: str, expected_error_text: str):
             with self.assertRaises(ConfigParseError) as e:
@@ -83,15 +85,15 @@ class TestConfig(unittest.TestCase):
             bugzilla_url = ""
             [people."person1"]
             """,
-            "`output_markdown_file` field is missing in person entry for "
+            "`full_name` field is missing in person entry for "
             "'person1'")
         check_error(
             """
             bugzilla_url = ""
             [people."person1"]
-            output_markdown_file = 1
+            full_name = 1
             """,
-            "`output_markdown_file` field in person entry for 'person1' must "
+            "`full_name` field in person entry for 'person1' must "
             "be a string")
         check(
             """
@@ -99,24 +101,24 @@ class TestConfig(unittest.TestCase):
             [milestones]
             [people."person1"]
             aliases = ["a"]
-            output_markdown_file = "person1.mdwn"
+            full_name = "Person One"
             [people."person2"]
             aliases = ["b"]
-            output_markdown_file = "person2.mdwn"
+            full_name = "Person Two"
             """,
             "Config(bugzilla_url='', people={"
             "'person1': Person(config=..., identifier='person1', "
-            "output_markdown_file='person1.mdwn', "
-            "aliases={'a'}, email=None), "
+            "full_name='Person One', "
+            "aliases=OrderedSet(['a']), email=None), "
             "'person2': Person(config=..., identifier='person2', "
-            "output_markdown_file='person2.mdwn', "
-            "aliases={'b'}, email=None)}, milestones={})")
+            "full_name='Person Two', "
+            "aliases=OrderedSet(['b']), email=None)}, milestones={})")
         check_error(
             """
             bugzilla_url = ""
             [people."person1"]
             email = 123
-            output_markdown_file = "person1.mdwn"
+            full_name = "Person One"
             """,
             "`email` field in person entry for 'person1' must be a string")
         check(
@@ -132,18 +134,19 @@ class TestConfig(unittest.TestCase):
             [milestones]
             [people."person1"]
             email = "email@example.com"
-            output_markdown_file = "person1.mdwn"
+            full_name = "Person One"
             """,
             "Config(bugzilla_url='', people={"
             "'person1': Person(config=..., identifier='person1', "
-            "output_markdown_file='person1.mdwn', "
-            "aliases=set(), email='email@example.com')}, milestones={})")
+            "full_name='Person One', "
+            "aliases=OrderedSet(), email='email@example.com')}, "
+            "milestones={})")
         check_error(
             """
             bugzilla_url = ""
             [people."person1"]
             blah = 123
-            output_markdown_file = "person1.mdwn"
+            full_name = "Person One"
             """,
             "unknown field in person entry for 'person1': `blah`")
         check_error(
@@ -151,10 +154,10 @@ class TestConfig(unittest.TestCase):
             bugzilla_url = ""
             [milestones]
             [people."person1"]
-            output_markdown_file = "person1.mdwn"
+            full_name = "Person One"
             [people."person2"]
             aliases = ["person1"]
-            output_markdown_file = "person2.mdwn"
+            full_name = "Person Two"
             """,
             "alias is not allowed to be the same as any person's identifier: "
             "in person entry for 'person2': 'person1' is also the identifier "
@@ -164,15 +167,57 @@ class TestConfig(unittest.TestCase):
             bugzilla_url = ""
             [milestones]
             [people."person1"]
-            output_markdown_file = "person1.mdwn"
+            full_name = "Person One"
             aliases = ["a"]
             [people."person2"]
             aliases = ["a"]
-            output_markdown_file = "person2.mdwn"
+            full_name = "Person Two"
             """,
-            "alias is not allowed to be the same as another person's alias: "
-            "in person entry for 'person2': 'a' is also an alias for person "
-            "'person1'")
+            "alias is not allowed to be the same as another person's alias, "
+            "email, or full_name: in person entry for 'person2': 'a' is also an alias, "
+            "email, or full_name for person 'person1'")
+        check_error(
+            """
+            bugzilla_url = ""
+            [milestones]
+            [people."person1"]
+            full_name = "Person One"
+            aliases = ["abc@example.com"]
+            [people."person2"]
+            email = "abc@example.com"
+            full_name = "Person Two"
+            """,
+            "email is not allowed to be the same as another person's alias, "
+            "email, or full_name: in person entry for 'person2': 'abc@example.com' is also "
+            "an alias, email, or full_name for person 'person1'")
+        check_error(
+            """
+            bugzilla_url = ""
+            [milestones]
+            [people."person1"]
+            full_name = "Person One"
+            aliases = ["Person Two"]
+            [people."person2"]
+            email = "abc@example.com"
+            full_name = "Person Two"
+            """,
+            "full_name is not allowed to be the same as another person's alias, "
+            "email, or full_name: in person entry for 'person2': 'Person Two' is also "
+            "an alias, email, or full_name for person 'person1'")
+        check_error(
+            """
+            bugzilla_url = ""
+            [milestones]
+            [people."person2"]
+            email = "abc@example.com"
+            full_name = "Person Two"
+            [people."person1"]
+            full_name = "Person One"
+            aliases = ["abc@example.com"]
+            """,
+            "alias is not allowed to be the same as another person's alias, "
+            "email, or full_name: in person entry for 'person1': 'abc@example.com' is also "
+            "an alias, email, or full_name for person 'person2'")
         check_error(
             """
             bugzilla_url = ""
@@ -232,19 +277,21 @@ class TestConfig(unittest.TestCase):
             [milestones]
             [people."person1"]
             aliases = ["person1_alias1", "alias1"]
-            output_markdown_file = "person1.mdwn"
+            full_name = "Person One"
             [people."person2"]
             aliases = ["person2_alias2", "alias2"]
-            output_markdown_file = "person2.mdwn"
+            full_name = "Person Two"
             """)
         person1 = config.people['person1']
         person2 = config.people['person2']
         self.assertEqual(config.all_names,
                          {
                              'person1': person1,
+                             'Person One': person1,
                              'person1_alias1': person1,
                              'alias1': person1,
                              'person2': person2,
+                             'Person Two': person2,
                              'person2_alias2': person2,
                              'alias2': person2,
                          })
@@ -315,14 +362,14 @@ class TestConfig(unittest.TestCase):
             [people."person1"]
             email = "person1@example.com"
             aliases = ["alias1"]
-            output_markdown_file = "person1.mdwn"
+            full_name = "Person One"
             [milestones]
             "Milestone 1" = { canonical_bug_id = 123 }
             """)),
             "Config(bugzilla_url='https://bugzilla.example.com/', "
             "people={'person1': Person(config=..., identifier='person1', "
-            "output_markdown_file='person1.mdwn', "
-            "aliases={'alias1'}, email='person1@example.com')}, "
+            "full_name='Person One', "
+            "aliases=OrderedSet(['alias1']), email='person1@example.com')}, "
             "milestones={'Milestone 1': Milestone(config=..., "
             "identifier='Milestone 1', canonical_bug_id=123)})")