From 870a2054253819d2f9b4e300c6762d6afac30d1f Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Tue, 26 Nov 2024 09:45:17 +0100 Subject: [PATCH] Extend tests for variable label presence Update unique label filtering to handle varying label presence --- src/conversion_logic.py | 9 +- ...abel.json => pr_api_output_no_labels.json} | 9 +- tests/pr_api_output_some_labels.json | 87 +++++ tests/test_github_query copy.py | 302 ++++++++++++++++++ tests/test_github_query.py | 22 +- 5 files changed, 407 insertions(+), 22 deletions(-) rename tests/{pr_api_output_missing_label.json => pr_api_output_no_labels.json} (89%) create mode 100644 tests/pr_api_output_some_labels.json create mode 100644 tests/test_github_query copy.py diff --git a/src/conversion_logic.py b/src/conversion_logic.py index d7ad700..9825bf1 100644 --- a/src/conversion_logic.py +++ b/src/conversion_logic.py @@ -23,7 +23,7 @@ def filter_unique_labels(pr_data: List[dict[str, str]]) -> List[str]: pr_data (dict): Github PR query result Returns: - list: List of unique labels strings found or `None`. + list: List of unique labels strings found or an empty list. """ labels: set[str] = set() @@ -40,12 +40,7 @@ def filter_unique_labels(pr_data: List[dict[str, str]]) -> List[str]: labels.add(label["name"]) logger.debug("PR labels found.") - label_list: list[str] = list(labels) - if not label_list: - logger.warning(f"No PR label data found") - return [] - - return label_list + return list(labels) def csv_string_to_list(input: str) -> List[str]: diff --git a/tests/pr_api_output_missing_label.json b/tests/pr_api_output_no_labels.json similarity index 89% rename from tests/pr_api_output_missing_label.json rename to tests/pr_api_output_no_labels.json index 2a97d4a..ab97800 100644 --- a/tests/pr_api_output_missing_label.json +++ b/tests/pr_api_output_no_labels.json @@ -5,14 +5,7 @@ }, { "body": "# Date file added\r\n\r\n## Summary\r\n\r\nSome awesome summary going on right here.\r\n\r\n## Root Cause Analysis\r\n\r\n[Issue Link](https://github.com/ynput/ci-testing/blob/develop/.github/ISSUE_TEMPLATE/bug_report.yml)
\r\nDate file so absolutely needed.\r\n\r\n## Changes\r\n\r\n\r\n* Run a command\r\n* Pipe its output to a text file\r\n* Commit dem stuff\r\n\r\n## Testing Strategy\r\n\r\nnahhhhh\r\n\r\n## Checklist\r\n\r\n* [x] The fix has been locally tested\r\n* [x] New unit tests have been added to prevent future regressions\r\n* [x] The documentation has been updated if necessary\r\n\r\n## Additional Notes\r\n\r\nNop", - "labels": [ - { - "id": "LA_kwDOMje8_88AAAABtOJ1Gw", - "name": "bug", - "description": "Something isn't working", - "color": "ff9195" - } - ], + "labels": [], "title": "Add date file" } ] \ No newline at end of file diff --git a/tests/pr_api_output_some_labels.json b/tests/pr_api_output_some_labels.json new file mode 100644 index 0000000..19a26e5 --- /dev/null +++ b/tests/pr_api_output_some_labels.json @@ -0,0 +1,87 @@ +[ + { + "body": "## Changelog Description\r\n\r\n\r\nThis fixes a case where looks failed to apply due to `None` values being present in the collected attributes.\r\nThese 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.\r\n\r\nExisting looks will now also apply correctly with `None` value in their look attributes, but the attributes with `None` values will be ignored with a warning.\r\n\r\n## Additional info\r\n\r\n\r\n## Testing notes:\r\n\r\n1. Load a model reference\r\n2. Create a string attribute, e.g. `test`\r\n3. Do not set any value for it.\r\n - Maya will return None for this attribute, e.g. select the object and run:\r\n```python\r\nfrom maya import cmds\r\nprint(cmds.getAttr(\".test\"))\r\n```\r\nIt will print `None`.\r\n4. Publish the look for this mesh\r\n5. The published `.json` file should have attribute value for `test` set to `\"\"`\r\n\r\nTo test the 'backwards compatible fix':\r\n- Publish the same look with `develop` branch. The value will be `null` in the `.json` file.`\r\n- OR, just open the last published `.json` file, and edit the `\"\"` value to `null`\r\n\r\nThen, confirm that applying the look succeeds without errors but with a warning regarding the `None` value when applying with this PR. For example in my test run it logged:\r\n\r\n```\r\n// Warning: ayon_maya.api.lib : Skipping setting |_GRP|cube_GEO.test with value 'None'\r\n```", + "id": "PR_kwDOMQ8b8s56Ps1m", + "labels": [ + { + "id": "LA_kwDOMQ8b8s8AAAABqmH60w", + "name": "sponsored", + "description": "Something isn't working", + "color": "FFA696" + }, + { + "id": "LA_kwDOMQ8b8s8AAAABtfdQMg", + "name": "sponsored", + "description": "This is directly sponsored by a client or community member", + "color": "FCD63D" + } + ], + "number": 89, + "title": "AY-6654 Look: Fix None values in collecting and applying attributes", + "url": "https://github.com/ynput/ayon-maya/pull/89" + }, + { + "body": "## Changelog Description\r\n\r\n\r\nFix name in settings to match with name of plug-in to ensure settings are actually applied\r\n\r\n## Additional info\r\n\r\n\r\nOriginally reported by @LiborBatek here: https://github.com/ynput/ayon-maya/pull/68#issuecomment-2288791598\r\n\r\n## Testing notes:\r\n\r\n1. Settings should adjust the extractor's defaults\r\n2. Disabling it in settings should hide the attributes from the publisher UI\r\n", + "id": "PR_kwDOMQ8b8s55oDx8", + "labels": [], + "number": 77, + "title": "Fix settings for Maya USD Animation Extractor", + "url": "https://github.com/ynput/ayon-maya/pull/77" + }, + { + "body": "## Changelog Description\r\n\r\n\r\nFix pixel aspect ratio / device aspect ratio getting messed up for Arnold renderer on render settings reset.\r\n\r\nAdditionally:\r\n- This now applies the resolution from the task entity, not the folder entity.\r\n- This now also applies pixel aspect ratio as defined on the entity.\r\n\r\n## Additional info\r\n\r\n\r\nThis fixes a bug when resetting render resolution for Arnold where on reset the pixel/device aspect ratio would be oddly set with a pixel aspect ratio that is not 1.0.\r\n\r\nE.g. left is before, right is after resetting render settings **without this PR**\r\n![image](https://github.com/user-attachments/assets/1b36d70b-2490-47f0-8731-d1ce5b20dfe9)\r\n\r\nAfter this PR the pixel aspect ratio will now adhere to what is specified on the task entity.\r\n_This bug was only occurring if the current renderer render settings were reset for was actively Arnold (mtoa) renderer._\r\n\r\n## Testing notes:\r\n\r\n1. Resetting render settings should work for the different renderers and should set the resolution (and pixel aspect ratio correctly!)\r\n - [x] Arnold (mtoa)\r\n - [x] Redshift (should work if Arnold works because it uses same attributes as Arnold)\r\n - [x] V-Ray (may be good to check because it uses a custom render settings node!)\r\n - [ ] Renderman (should work if Arnold works because it uses same attributes as Arnold)\r\n\r\nNote that this is about **Set Render Settings** or the feature that it automatically does so on creating a render publish instance in the scene (enabled by default).\r\n\r\n![image](https://github.com/user-attachments/assets/ad8b0534-0921-4dc2-add9-eb276326030f)\r\n", + "id": "PR_kwDOMQ8b8s55L5zV", + "labels": [ + { + "id": "LA_kwDOMQ8b8s8AAAABqmH60w", + "name": "type: bugfix", + "description": "Something isn't working", + "color": "FFA696" + }, + { + "id": "LA_kwDOMQ8b8s8AAAABqmH62w", + "name": "type: enhancement", + "description": "Improvement of existing functionality or minor addition", + "color": "b9f29d" + }, + { + "id": "LA_kwDOMQ8b8s8AAAABtfdQMg", + "name": "sponsored", + "description": "This is directly sponsored by a client or community member", + "color": "FCD63D" + } + ], + "number": 75, + "title": "Improve applying render resolution and aspect ratio on render settings reset", + "url": "https://github.com/ynput/ayon-maya/pull/75" + }, + { + "body": "## Changelog Description\r\n\r\n\r\nOn Maya scene exports only include the relevant history for the selected nodes downstream and upstream and not upstream, and also their downstream descendant children.\r\n\r\n## Additional info\r\n\r\n\r\nNote: This may affect maya scene exports, camera rig exports and layout exports. However, I do feel this is a way more sensible default behavior on exports _with_ construction history enabled.\r\n\r\nWith this change, if you have a hierarchy like:\r\n```\r\ngrp/\r\n obj1\r\n obj2\r\n```\r\nAnd `obj1` is inside the instance then after this PR `obj2` is not included.\r\nBefore this PR all other descendents from upstream groups would be included, regardless of whether they were \"inputs\" to the `obj1`.\r\n\r\nAfter this PR, if `obj2` is an input connection to `obj1` (e.g. there are active constraints driving `obj1` or some other connections driving it) then `obj2` **will still be included.**\r\n\r\nAs such, only objects actively contributing to members of the instance will still be included in the output.\r\n\r\n## Testing notes:\r\n\r\n1. Recreate the aforementioned hierarchy from additional info.\r\n2. Publish `obj1` - it should not include `obj2`\r\n3. Now make a connection from `obj2` to `obj1` (e.g. translate connection)\r\n4. Now `obj2` should also be included in `obj2`.\r\n5. Now disconnect the connection, and key `obj1` transforms.\r\n6. The keys should be exported along just fine.", + "id": "PR_kwDOMQ8b8s542vNM", + "labels": [], + "number": 71, + "title": "Maya Scene exports do not default to including nodes that not children of members", + "url": "https://github.com/ynput/ayon-maya/pull/71" + }, + { + "body": "## Changelog Description\r\n\r\n\r\nValidate unique names only within the instance not in full scene\r\n\r\n## Additional info\r\n\r\n\r\nThis is allowed:\r\n![image](https://github.com/user-attachments/assets/ce25d2aa-fa3a-4b25-b0ff-b58ebe7b6124)\r\n\r\nThis is not allowed:\r\n![image](https://github.com/user-attachments/assets/67b3099b-18a1-4779-ae1c-422887675ba8)\r\n\r\nThe validation only checks for member transforms that are included in the export instance.\r\n\r\n![image](https://github.com/user-attachments/assets/e6950101-1210-423b-afe8-6797c33ea5bf)\r\n\r\n## Testing notes:\r\n\r\nMake sure to enable the validator: `ayon+settings://maya/publish/ValidateUniqueNames/enabled`\r\n\r\n1. Create a scene with non-unique node names (e.g. see screenshots above).\r\n2. When both included in the instance it should not be allowed, \r\n3. Otherwise when just present elsewhere in the scene unrelated to the export it should be allowed.\r\n", + "id": "PR_kwDOMQ8b8s54uX2I", + "labels": [ + { + "id": "LA_kwDOMQ8b8s8AAAABqmH62w", + "name": "type: enhancement", + "description": "Improvement of existing functionality or minor addition", + "color": "b9f29d" + }, + { + "id": "LA_kwDOMQ8b8s8AAAABtfdQMg", + "name": "sponsored", + "description": "This is directly sponsored by a client or community member", + "color": "FCD63D" + } + ], + "number": 70, + "title": "Validate unique names only within the instance not in full scene", + "url": "https://github.com/ynput/ayon-maya/pull/70" + } + ] \ No newline at end of file diff --git a/tests/test_github_query copy.py b/tests/test_github_query copy.py new file mode 100644 index 0000000..bdd7bc1 --- /dev/null +++ b/tests/test_github_query copy.py @@ -0,0 +1,302 @@ +from typing import Any, Literal, List +import json +import pytest + +from src import conversion_logic + +@pytest.fixture +def pr_api_output() -> List[dict[str, Any]]: + with open("pr_api_output.json") as file: + return json.load(file) + +@pytest.fixture +def pr_api_output_no_labels() -> List[dict[str, Any]]: + with open("pr_api_output_no_labels.json") as file: + return json.load(file) + +@pytest.fixture +def pr_api_output_some_labels() -> List[dict[str, Any]]: + with open("pr_api_output_some_labels.json") as file: + return json.load(file) + +@pytest.fixture +def major_bump() -> List[str]: + return ["epic"] + +@pytest.fixture +def major_bump_no_list() -> Literal['epic']: + return "epic" + +@pytest.fixture +def merged_pr_samples(): + with open("merged_pr_query.json") as file: + return json.load(file) + +@pytest.fixture +def changelog_markdown() -> str: + with open("formatted_changelog.md") as file: + return file.read() + +@pytest.fixture +def changelog_markdown_icons() -> str: + with open("formatted_changelog_icons.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]: + return ["feature", "enhancement"] + +@pytest.fixture +def patch_bump() -> list[str]: + return ["bugfix"] + +@pytest.fixture +def pr_labels_bug() -> list[str]: + return ["bugfix"] + +@pytest.fixture +def pr_labels_enhancement() -> list[str]: + return ["bugfix", "documentation", "feature", "enhancement"] + +@pytest.fixture +def pr_labels_epic() -> List[str]: + return ["bugfix", "documentation", "feature", "enhancement", "epic"] + +@pytest.fixture +def pr_labels_wrong_labels() -> list[str]: + return ["documentation", "wontfix"] + +@pytest.fixture +def pr_labels_empty_list() -> list[Any]: + return [] + +@pytest.fixture +def pr_labels_none() -> None: + return None + +@pytest.fixture +def csv_string_spaces() -> Literal['bugfix, enhancement, feature']: + return "bugfix, enhancement, feature" + +@pytest.fixture +def csv_string_no_spaces() -> Literal['bugfix,enhancement,feature']: + return "bugfix,enhancement,feature" + +@pytest.fixture +def csv_string_no_comma() -> Literal['bugfix']: + return "bugfix" + +@pytest.fixture +def empty_string() -> str: + return "" + +@pytest.fixture +def changelog_label_list() -> list[str]: + return ["type: enhancement", "type: bugfix", "type: maintenance"] + +@pytest.fixture +def label_with_emote() -> str: + return "type: bugfix(🐛)" + +@pytest.fixture +def label_type_prefix() -> str: + return "type: bugfix" + +@pytest.fixture +def changelog_label_list_icons() -> list[str]: + return ["feature(🎉)", "type: enhancement(💚)", "type: bugfix(🐛)", "type: maintenance"] + +@pytest.fixture +def changelog_exclude_label_list() -> List[str]: + return ["sponsored"] + + +# Get PR Label test-cases + +def test_get_labels(pr_api_output: List[dict[str, Any]]) -> None: + labels: List[str] = conversion_logic.filter_unique_labels(pr_data=pr_api_output) + + assert isinstance(labels, list) + assert set(labels) == {"bugfix", "enhancement"} + +def test_get_labels_no_labels(pr_api_output_no_labels: List[dict[str, Any]]) -> None: + labels: List[str] = conversion_logic.filter_unique_labels(pr_data=pr_api_output_no_labels) + + assert labels == [] + + +def test_get_labels_some_labels(pr_api_output_no_labels: List[dict[str, Any]]) -> None: + labels: List[str] = conversion_logic.filter_unique_labels(pr_data=pr_api_output_no_labels) + + assert labels == [] + +# Convert repo label list + +def test_csv_string_to_list_spaces(csv_string_spaces: Literal['bugfix, enhancement, feature']) -> None: + string_list: List[str] = conversion_logic.csv_string_to_list(csv_string_spaces) + string_list: List[str] = conversion_logic.csv_string_to_list(csv_string_spaces) + + assert string_list == ["bugfix", "enhancement", "feature"] + +def test_csv_string_to_list_no_spaces(csv_string_no_spaces: Literal['bugfix,enhancement,feature']) -> None: + string_list: List[str] = conversion_logic.csv_string_to_list(csv_string_no_spaces) + string_list: List[str] = conversion_logic.csv_string_to_list(csv_string_no_spaces) + + assert string_list == ["bugfix", "enhancement", "feature"] + +def test_csv_string_to_list_no_comma(csv_string_no_comma: Literal['bugfix']) -> None: + string_list: List[str] = conversion_logic.csv_string_to_list(csv_string_no_comma) + string_list: List[str] = conversion_logic.csv_string_to_list(csv_string_no_comma) + + assert string_list == ["bugfix"] + +def test_csv_string_to_list_empty(empty_string: Literal['']) -> None: + string_list: List[str] = conversion_logic.csv_string_to_list(empty_string) + string_list: List[str] = conversion_logic.csv_string_to_list(empty_string) + + assert string_list == [] + + +# Version Increment test-cases + +def test_get_version_increment_patch(minor_bump: List[str], patch_bump: List[str], pr_labels_bug: List[str]) -> None: + increment = conversion_logic.get_version_increment( + pr_label_list=pr_labels_bug, + patch_bump_list=patch_bump, + minor_bump_list=minor_bump, + ) + + assert increment == "patch" + +def test_get_version_increment_minor(minor_bump: List[str], patch_bump: List[str], pr_labels_enhancement: List[str]) -> None: + increment = conversion_logic.get_version_increment( + pr_label_list=pr_labels_enhancement, + patch_bump_list=patch_bump, + minor_bump_list=minor_bump, + ) + + assert increment == "minor" + +def test_get_version_increment_major(minor_bump: List[str], patch_bump: List[str], major_bump: List[str], pr_labels_epic: List[str]) -> None: + increment = conversion_logic.get_version_increment( + pr_label_list=pr_labels_epic, + patch_bump_list=patch_bump, + minor_bump_list=minor_bump, + major_bump_list=major_bump, + ) + + assert increment == "major" + +def test_get_version_increment_wrong_labels(minor_bump: List[str], patch_bump: List[str], pr_labels_wrong_labels: List[str]): + increment = conversion_logic.get_version_increment( + pr_label_list=pr_labels_wrong_labels, + patch_bump_list=patch_bump, + minor_bump_list=minor_bump, + ) + + assert increment == "" + +def test_get_version_increment_none(minor_bump: List[str], patch_bump: List[str], pr_labels_none: None) -> None: + increment = conversion_logic.get_version_increment( + pr_label_list=pr_labels_none, + patch_bump_list=patch_bump, + minor_bump_list=minor_bump, + ) + + assert increment == "" + +def test_get_version_increment_empty_list(minor_bump: List[str], patch_bump: List[str], pr_labels_empty_list: List[Any]) -> None: + increment = conversion_logic.get_version_increment( + pr_label_list=pr_labels_empty_list, + patch_bump_list=patch_bump, + minor_bump_list=minor_bump, + ) + + assert increment == "" + +def test_get_version_increment_no_list(minor_bump: List[str], patch_bump: List[str], major_bump_no_list: Literal['epic'], pr_labels_epic: List[str]) -> None: + with pytest.raises(ValueError, match="must be a list"): + conversion_logic.get_version_increment( + pr_label_list=pr_labels_epic, + patch_bump_list=patch_bump, + minor_bump_list=minor_bump, + major_bump_list=major_bump_no_list, + ) + + +# Changelog test-cases + +def test_filter_changes_per_label_types(merged_pr_samples: List[dict[str, str]], changelog_label_list: List[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) + + 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) + + assert changelog_result == changelog_markdown + +def test_format_changelog_markdown_no_data(changelog_label_list: List[str]) -> None: + filtered_pr_list: List[conversion_logic.Changelog] = conversion_logic.filter_changes_per_label(pr_data=[], changelog_label_list=changelog_label_list) + changelog_result: str = conversion_logic.format_changelog_markdown(changes=filtered_pr_list, changelog_label_list=changelog_label_list) + + assert changelog_result == "# Changelog\n" + +def test_filter_emote(label_with_emote: str) -> None: + filter_result: str = conversion_logic.filter_emote(text=label_with_emote) + + assert filter_result == "type: bugfix" + +def test_filter_emote_no_emote(label_type_prefix: str) -> None: + filter_result: str = conversion_logic.filter_emote(text=label_type_prefix) + + assert filter_result == "type: bugfix" + +def test_filter_emote_empty(empty_string: str) -> None: + filter_result: str = conversion_logic.filter_emote(text=empty_string) + + assert filter_result == "" + +def test_format_label_emote(label_with_emote: str) -> None: + formatted_label: str = conversion_logic.format_label(text=label_with_emote) + + assert formatted_label == "🐛 **Bugfix**" + +def test_format_label_empty(empty_string: str) -> None: + formatted_label: str = conversion_logic.format_label(text=empty_string) + + assert formatted_label == "" + +def test_format_label(label_type_prefix: str) -> None: + formatted_label: str = conversion_logic.format_label(text=label_type_prefix) + + assert formatted_label == "**Bugfix**" + +def test_get_changelog_description_no_descprition(): + pr_body = "## Changelog\r\n\r\n\r\nOn Maya scene exports only include the relevant history for the selected nodes downstream and upstream and not upstream, and also their downstream descendant children.\r\n\r\n## Additional info\r\n\r\n\r\nNote: This may affect maya scene exports, camera rig exports and layout exports. However, I do feel this is a way more sensible default behavior on exports _with_ construction history enabled.\r\n\r\nWith this change, if you have a hierarchy like:\r\n```\r\ngrp/\r\n obj1\r\n obj2\r\n```\r\nAnd `obj1` is inside the instance then after this PR `obj2` is not included.\r\nBefore this PR all other descendents from upstream groups would be included, regardless of whether they were \"inputs\" to the `obj1`.\r\n\r\nAfter this PR, if `obj2` is an input connection to `obj1` (e.g. there are active constraints driving `obj1` or some other connections driving it) then `obj2` **will still be included.**\r\n\r\nAs such, only objects actively contributing to members of the instance will still be included in the output.\r\n\r\n## Testing notes:\r\n\r\n1. Recreate the aforementioned hierarchy from additional info.\r\n2. Publish `obj1` - it should not include `obj2`\r\n3. Now make a connection from `obj2` to `obj1` (e.g. translate connection)\r\n4. Now `obj2` should also be included in `obj2`.\r\n5. Now disconnect the connection, and key `obj1` transforms.\r\n6. The keys should be exported along just fine." + changelog_desc_result: List[str] = conversion_logic.get_changelog_description(pr_body) + + assert changelog_desc_result == [] + +def test_format_changelog_markdown_icons(merged_pr_samples: List[dict[str, str]], changelog_label_list_icons: List[str], changelog_markdown_icons: 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_icons) + changelog_result: str = conversion_logic.format_changelog_markdown(changes=filtered_pr_list, changelog_label_list=changelog_label_list_icons) + + assert changelog_result == changelog_markdown_icons + +# TODO add test for mix of labels with type and without type labels diff --git a/tests/test_github_query.py b/tests/test_github_query.py index 6004e37..3d8f236 100644 --- a/tests/test_github_query.py +++ b/tests/test_github_query.py @@ -10,8 +10,13 @@ def pr_api_output() -> List[dict[str, Any]]: return json.load(file) @pytest.fixture -def pr_api_output_missing_label() -> List[dict[str, Any]]: - with open("pr_api_output_missing_label.json") as file: +def pr_api_output_no_labels() -> List[dict[str, Any]]: + with open("pr_api_output_no_labels.json") as file: + return json.load(file) + +@pytest.fixture +def pr_api_output_some_labels() -> List[dict[str, Any]]: + with open("pr_api_output_some_labels.json") as file: return json.load(file) @pytest.fixture @@ -123,12 +128,17 @@ def test_get_labels(pr_api_output: List[dict[str, Any]]) -> None: assert isinstance(labels, list) assert set(labels) == {"bugfix", "enhancement"} -def test_get_labels_missing_input(pr_api_output_missing_label: List[dict[str, Any]]) -> None: - labels: List[str] = conversion_logic.filter_unique_labels(pr_data=pr_api_output_missing_label) +def test_get_labels_no_labels(pr_api_output_no_labels: List[dict[str, Any]]) -> None: + labels: List[str] = conversion_logic.filter_unique_labels(pr_data=pr_api_output_no_labels) assert labels == [] +def test_get_labels_some_labels(pr_api_output_some_labels: List[dict[str, Any]]) -> None: + labels: List[str] = conversion_logic.filter_unique_labels(pr_data=pr_api_output_some_labels) + + assert set(labels) == {"type: enhancement", "type: bugfix", "sponsored"} + # Convert repo label list def test_csv_string_to_list_spaces(csv_string_spaces: Literal['bugfix, enhancement, feature']) -> None: @@ -277,7 +287,7 @@ def test_format_label(label_type_prefix: str) -> None: assert formatted_label == "**Bugfix**" -def test_get_changelog_description_no_descprition(): +def test_get_changelog_description_no_description() -> None: pr_body = "## Changelog\r\n\r\n\r\nOn Maya scene exports only include the relevant history for the selected nodes downstream and upstream and not upstream, and also their downstream descendant children.\r\n\r\n## Additional info\r\n\r\n\r\nNote: This may affect maya scene exports, camera rig exports and layout exports. However, I do feel this is a way more sensible default behavior on exports _with_ construction history enabled.\r\n\r\nWith this change, if you have a hierarchy like:\r\n```\r\ngrp/\r\n obj1\r\n obj2\r\n```\r\nAnd `obj1` is inside the instance then after this PR `obj2` is not included.\r\nBefore this PR all other descendents from upstream groups would be included, regardless of whether they were \"inputs\" to the `obj1`.\r\n\r\nAfter this PR, if `obj2` is an input connection to `obj1` (e.g. there are active constraints driving `obj1` or some other connections driving it) then `obj2` **will still be included.**\r\n\r\nAs such, only objects actively contributing to members of the instance will still be included in the output.\r\n\r\n## Testing notes:\r\n\r\n1. Recreate the aforementioned hierarchy from additional info.\r\n2. Publish `obj1` - it should not include `obj2`\r\n3. Now make a connection from `obj2` to `obj1` (e.g. translate connection)\r\n4. Now `obj2` should also be included in `obj2`.\r\n5. Now disconnect the connection, and key `obj1` transforms.\r\n6. The keys should be exported along just fine." changelog_desc_result: List[str] = conversion_logic.get_changelog_description(pr_body) @@ -288,5 +298,3 @@ def test_format_changelog_markdown_icons(merged_pr_samples: List[dict[str, str]] changelog_result: str = conversion_logic.format_changelog_markdown(changes=filtered_pr_list, changelog_label_list=changelog_label_list_icons) assert changelog_result == changelog_markdown_icons - -# TODO add test for mix of labels with type and without type labels