Skip to content

Commit

Permalink
Add unit-test for changelog description formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
philnewm committed Nov 5, 2024
1 parent 3dde7bb commit 031eb3e
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
8 changes: 7 additions & 1 deletion src/conversion_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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("<!--"):
continue
changelog += f"{desc_line}\n"

changelog += f"___\n\n"
changelog += f"\n___\n\n"
changelog += f"</details>\n"

return changelog
15 changes: 15 additions & 0 deletions tests/changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## Changelog Description

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

## Additional info

Separated from #2

## Testing notes:

1. Loading of the USD data should work as intended into Maya USD Proxy Shapes.
2. Managing (updating) and removal via scene inventory should also do what is expected.
6 changes: 0 additions & 6 deletions tests/formatted_changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<details>
<summary>Improve applying render resolution and aspect ratio on render settings reset - <a href="https://github.com/ynput/ayon-maya/pull/75")>#75</a></summary>

<!-- Paragraphs contain detailed information on the changes made to the product or service, providing an in-depth description of the updates and enhancements. They can be used to explain the reasoning behind the changes, or to highlight the importance of the new features. Paragraphs can often include links to further information or support documentation. -->

Fix pixel aspect ratio / device aspect ratio getting messed up for Arnold renderer on render settings reset.

Expand All @@ -19,7 +18,6 @@ ___
<details>
<summary>Validate unique names only within the instance not in full scene - <a href="https://github.com/ynput/ayon-maya/pull/70")>#70</a></summary>

<!-- Paragraphs contain detailed information on the changes made to the product or service, providing an in-depth description of the updates and enhancements. They can be used to explain the reasoning behind the changes, or to highlight the importance of the new features. Paragraphs can often include links to further information or support documentation. -->

Validate unique names only within the instance not in full scene

Expand All @@ -32,7 +30,6 @@ ___
<details>
<summary>AY-6654 Look: Fix None values in collecting and applying attributes - <a href="https://github.com/ynput/ayon-maya/pull/89")>#89</a></summary>

<!-- Paragraphs contain detailed information on the changes made to the product or service, providing an in-depth description of the updates and enhancements. They can be used to explain the reasoning behind the changes, or to highlight the importance of the new features. Paragraphs can often include links to further information or support documentation. -->

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.
Expand All @@ -45,7 +42,6 @@ ___
<details>
<summary>Fix settings for Maya USD Animation Extractor - <a href="https://github.com/ynput/ayon-maya/pull/77")>#77</a></summary>

<!-- Paragraphs contain detailed information on the changes made to the product or service, providing an in-depth description of the updates and enhancements. They can be used to explain the reasoning behind the changes, or to highlight the importance of the new features. Paragraphs can often include links to further information or support documentation. -->

Fix name in settings to match with name of plug-in to ensure settings are actually applied

Expand All @@ -55,7 +51,6 @@ ___
<details>
<summary>Improve applying render resolution and aspect ratio on render settings reset - <a href="https://github.com/ynput/ayon-maya/pull/75")>#75</a></summary>

<!-- Paragraphs contain detailed information on the changes made to the product or service, providing an in-depth description of the updates and enhancements. They can be used to explain the reasoning behind the changes, or to highlight the importance of the new features. Paragraphs can often include links to further information or support documentation. -->

Fix pixel aspect ratio / device aspect ratio getting messed up for Arnold renderer on render settings reset.

Expand All @@ -69,7 +64,6 @@ ___
<details>
<summary>Maya Scene exports do not default to including nodes that not children of members - <a href="https://github.com/ynput/ayon-maya/pull/71")>#71</a></summary>

<!-- Paragraphs contain detailed information on the changes made to the product or service, providing an in-depth description of the updates and enhancements. They can be used to explain the reasoning behind the changes, or to highlight the importance of the new features. Paragraphs can often include links to further information or support documentation. -->

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.

Expand Down
16 changes: 14 additions & 2 deletions tests/test_github_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 031eb3e

Please sign in to comment.