From 031eb3e0d5a3ed36dc9a009a0caecb228744898b Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Tue, 5 Nov 2024 11:35:45 +0100 Subject: [PATCH] Add unit-test for changelog description formatting --- src/conversion_logic.py | 8 +++++++- tests/changelog.md | 15 +++++++++++++++ tests/formatted_changelog.md | 6 ------ tests/test_github_query.py | 16 ++++++++++++++-- 4 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 tests/changelog.md diff --git a/src/conversion_logic.py b/src/conversion_logic.py index c43851c..011b758 100644 --- a/src/conversion_logic.py +++ b/src/conversion_logic.py @@ -145,6 +145,10 @@ def get_changelog_description(pr_body: str, changelog_desc: str ="## Changelog D if changelog_section: description_lines.append(line.strip()) + for index in [0, -1]: + if not description_lines[index]: + description_lines.pop(index) + return description_lines @@ -177,9 +181,11 @@ def format_changelog_markdown(changes: List[Changelog], changelog_label_list: Li changelog_desc: List[str] = get_changelog_description(change.body, changelog_desc="## Changelog Description", heading="##") for desc_line in changelog_desc: + if desc_line.startswith(" Fix pixel aspect ratio / device aspect ratio getting messed up for Arnold renderer on render settings reset. @@ -19,7 +18,6 @@ ___
Validate unique names only within the instance not in full scene - #70 - Validate unique names only within the instance not in full scene @@ -32,7 +30,6 @@ ___
AY-6654 Look: Fix None values in collecting and applying attributes - #89 - This fixes a case where looks failed to apply due to `None` values being present in the collected attributes. These will now be ignored in collected. There's an edge case where Maya returns `None` for string attributes that have no values set - those are captured now explicitly to just `""` to still collect and apply them later. @@ -45,7 +42,6 @@ ___
Fix settings for Maya USD Animation Extractor - #77 - Fix name in settings to match with name of plug-in to ensure settings are actually applied @@ -55,7 +51,6 @@ ___
Improve applying render resolution and aspect ratio on render settings reset - #75 - Fix pixel aspect ratio / device aspect ratio getting messed up for Arnold renderer on render settings reset. @@ -69,7 +64,6 @@ ___
Maya Scene exports do not default to including nodes that not children of members - #71 - On Maya scene exports only include the relevant history for the selected nodes downstream and upstream and not upstream, and also their downstream descendant children. diff --git a/tests/test_github_query.py b/tests/test_github_query.py index 51cbed6..9bd971b 100644 --- a/tests/test_github_query.py +++ b/tests/test_github_query.py @@ -71,6 +71,15 @@ def merged_pr_samples(): def changelog_markdown() -> str: with open("formatted_changelog.md") as file: return file.read() + +@pytest.fixture +def changelog_body() -> str: + with open("changelog.md") as file: + return file.read() + +@pytest.fixture +def changelog_description() -> List[str]: + return ['Some more information', '', '- Prototype loading of USD references into a Maya USD proxy while keeping it managed by the pipeline', '- Prototype loading of Maya references into a Maya USD proxy while keeping it managed by the pipeline'] @pytest.fixture def minor_bump() -> list[str]: @@ -244,13 +253,16 @@ def test_filter_changes_per_label_types(merged_pr_samples: List[dict[str, str]], assert all(isinstance(changelog, conversion_logic.Changelog) for changelog in filtered_pr_list) +def test_get_changelog_description(changelog_body: str, changelog_description: str) -> None: + filtered_changelog: List[str] = conversion_logic.get_changelog_description(changelog_body) + + assert filtered_changelog == changelog_description def test_format_changelog_markdown(merged_pr_samples: List[dict[str, str]], changelog_label_list: List[str], changelog_markdown: str) -> None: filtered_pr_list: List[conversion_logic.Changelog] = conversion_logic.filter_changes_per_label(pr_data=merged_pr_samples, changelog_label_list=changelog_label_list) changelog_result: str = conversion_logic.format_changelog_markdown(changes=filtered_pr_list, changelog_label_list=changelog_label_list) - # print(changelog_result) - + print(changelog_result) assert changelog_result == changelog_markdown def test_format_changelog_markdown_no_data(changelog_label_list: List[str]) -> None: