X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fbudget_sync%2Ftest%2Ftest_write_budget_markdown.py;fp=src%2Fbudget_sync%2Ftest%2Ftest_write_budget_markdown.py;h=e26e92abf10c902e7800b8638aa5c3960cc90640;hb=1677f851d34271d1c01c3070cf491116c26b85bd;hp=16987670289c6c57499cdef8d15e3e463742335b;hpb=2d48cb8c10a91fc858fe847d4b665cf79633c4b0;p=utils.git diff --git a/src/budget_sync/test/test_write_budget_markdown.py b/src/budget_sync/test/test_write_budget_markdown.py index 1698767..e26e92a 100644 --- a/src/budget_sync/test/test_write_budget_markdown.py +++ b/src/budget_sync/test/test_write_budget_markdown.py @@ -1,11 +1,12 @@ import unittest from budget_sync.config import Config +from budget_sync.ordered_set import OrderedSet from budget_sync.test.mock_bug import MockBug from budget_sync.test.mock_path import MockFilesystem, MockPath, DIR from budget_sync.test.test_mock_path import make_filesystem_and_report_if_error from budget_sync.budget_graph import BudgetGraph from budget_sync.write_budget_markdown import ( - write_budget_markdown, DisplayStatus, markdown_escape) + write_budget_markdown, DisplayStatus, markdown_escape, markdown_for_person) from budget_sync.util import BugStatus @@ -70,7 +71,7 @@ class TestWriteBudgetMarkdown(unittest.TestCase): cf_total_budget="0", cf_nlnet_milestone=None, cf_payees_list="", - summary="", + summary="summary1", assigned_to="person1@example.com"), ], config) self.assertEqual([], budget_graph.get_errors()) @@ -121,7 +122,7 @@ class TestWriteBudgetMarkdown(unittest.TestCase): cf_total_budget="1000", cf_nlnet_milestone="milestone 1", cf_payees_list="", - summary="", + summary="summary1", assigned_to="person1@example.com"), MockBug(bug_id=2, cf_budget_parent=1, @@ -129,7 +130,7 @@ class TestWriteBudgetMarkdown(unittest.TestCase): cf_total_budget="300", cf_nlnet_milestone="milestone 1", cf_payees_list="person2 = 100", - summary="", + summary="summary2", assigned_to="person1@example.com"), MockBug(bug_id=3, cf_budget_parent=2, @@ -137,7 +138,7 @@ class TestWriteBudgetMarkdown(unittest.TestCase): cf_total_budget="200", cf_nlnet_milestone="milestone 1", cf_payees_list="person1 = 100", - summary="", + summary="summary3", assigned_to="person1@example.com"), MockBug(bug_id=4, cf_budget_parent=3, @@ -145,7 +146,7 @@ class TestWriteBudgetMarkdown(unittest.TestCase): cf_total_budget="100", cf_nlnet_milestone="milestone 1", cf_payees_list="person2 = 100", - summary="", + summary="summary4", assigned_to="person1@example.com"), ], config) self.assertEqual([], budget_graph.get_errors()) @@ -171,10 +172,16 @@ class TestWriteBudgetMarkdown(unittest.TestCase): b'### milestone 1\n' b'\n' b'* [Bug #3](https://bugzilla.example.com/show_bug.cgi?id=3):\n' - b' \n' + b' summary3\n' b' * €100 which is the total amount\n' b' * this task is part of MoU Milestone\n' b' [Bug #2](https://bugzilla.example.com/show_bug.cgi?id=2)\n' + b'\n' + b'#### MoU Milestone subtotals for not yet submitted payments\n' + b'\n' + b'* [Bug #2](https://bugzilla.example.com/show_bug.cgi?id=2):\n' + b' summary2\n' + b' * subtotal €100 out of total including subtasks of €300\n' ), '/output_dir/person2.mdwn': ( b'\n' @@ -192,16 +199,116 @@ class TestWriteBudgetMarkdown(unittest.TestCase): b'### milestone 1\n' b'\n' b'* [Bug #2](https://bugzilla.example.com/show_bug.cgi?id=2):\n' - b' \n' + b' summary2\n' b' * €100 which is the total amount\n' b' * this task is a MoU Milestone\n' b'* [Bug #4](https://bugzilla.example.com/show_bug.cgi?id=4):\n' - b' \n' + b' summary4\n' b' * €100 which is the total amount\n' b' * this task is part of MoU Milestone\n' b' [Bug #2](https://bugzilla.example.com/show_bug.cgi?id=2)\n' + b'\n' + b'#### MoU Milestone subtotals for not yet submitted payments\n' + b'\n' + b'* [Bug #2](https://bugzilla.example.com/show_bug.cgi?id=2):\n' + b' summary2\n' + b' * subtotal €200 out of total including subtasks of €300\n' ), }, filesystem) + + def test_markdown_for_person(self): + config = Config.from_str( + """ + bugzilla_url = "https://bugzilla.example.com/" + [milestones] + "milestone 1" = { canonical_bug_id = 1 } + [people."person1"] + email = "person1@example.com" + full_name = "Person One" + [people."person2"] + full_name = "Person Two" + """) + budget_graph = BudgetGraph([ + MockBug(bug_id=1, + cf_budget_parent=None, + cf_budget="600", + cf_total_budget="1000", + cf_nlnet_milestone="milestone 1", + cf_payees_list="", + summary="summary1", + assigned_to="person1@example.com"), + MockBug(bug_id=2, + cf_budget_parent=1, + cf_budget="100", + cf_total_budget="400", + cf_nlnet_milestone="milestone 1", + cf_payees_list="person2 = 100", + summary="summary2", + assigned_to="person1@example.com"), + MockBug(bug_id=3, + cf_budget_parent=2, + cf_budget="100", + cf_total_budget="300", + cf_nlnet_milestone="milestone 1", + cf_payees_list="person1 = 100", + summary="summary3", + assigned_to="person1@example.com"), + MockBug(bug_id=4, + cf_budget_parent=3, + cf_budget="100", + cf_total_budget="100", + cf_nlnet_milestone="milestone 1", + cf_payees_list="person2 = 100", + summary="summary4", + assigned_to="person1@example.com"), + MockBug(bug_id=5, + cf_budget_parent=3, + cf_budget="100", + cf_total_budget="100", + cf_nlnet_milestone="milestone 1", + cf_payees_list="person2 = 100", + summary="summary4", + assigned_to="person1@example.com"), + ], config) + self.assertEqual([], budget_graph.get_errors()) + person = config.all_names["person2"] + nodes_subset = OrderedSet([budget_graph.nodes[2], + budget_graph.nodes[3], + budget_graph.nodes[4]]) + expected = [ + '\n', + '\n', + '# Person Two (person2)\n', + '\n', + '\n', + '\n', + '# Status Tracking\n', + '\n', + '\n', + '## Payment not yet submitted\n', + '\n', + '\n', + '### milestone 1\n', + '\n', + '* [Bug #2](https://bugzilla.example.com/show_bug.cgi?id=2):\n', + ' summary2\n', + ' * €100 which is the total amount\n', + ' * this task is a MoU Milestone\n', + '* [Bug #4](https://bugzilla.example.com/show_bug.cgi?id=4):\n', + ' summary4\n', + ' * €100 which is the total amount\n', + ' * this task is part of MoU Milestone\n', + ' [Bug #2](https://bugzilla.example.com/show_bug.cgi?id=2)\n', + '\n', + '#### MoU Milestone subtotals for not yet submitted payments\n', + '\n', + '* [Bug #2](https://bugzilla.example.com/show_bug.cgi?id=2):\n', + ' summary2\n', + ' * subtotal €200 out of total including subtasks of €400\n', + ] + self.assertEqual(markdown_for_person( + budget_graph, person, nodes_subset).splitlines(keepends=True), + expected) # TODO: add more test cases