From b208ecb150803bd8e79754050255da762e34c998 Mon Sep 17 00:00:00 2001 From: Gwyn Uttmark Date: Mon, 14 Oct 2024 11:32:36 -0600 Subject: [PATCH] Add integration tests, fix bug with release dates being required, add flexible dates to brassy release note date fields --- pytest.ini | 3 + src/brassy/templates/release_yaml_template.py | 24 ++- tests/inputs/barebones.yaml | 6 + tests/inputs/fully-featured.yaml | 141 ++++++++++++++++++ tests/inputs/mostly-featured.yaml | 123 +++++++++++++++ tests/inputs/to-prune.yaml | 123 +++++++++++++++ tests/outputs/barebones.rst | 16 ++ tests/outputs/fully-featured.rst | 103 +++++++++++++ tests/outputs/mostly-featured.rst | 105 +++++++++++++ tests/outputs/pruned.yaml | 113 ++++++++++++++ tests/test_integ.py | 52 +++++++ 11 files changed, 808 insertions(+), 1 deletion(-) create mode 100644 pytest.ini create mode 100644 tests/inputs/barebones.yaml create mode 100644 tests/inputs/fully-featured.yaml create mode 100644 tests/inputs/mostly-featured.yaml create mode 100644 tests/inputs/to-prune.yaml create mode 100644 tests/outputs/barebones.rst create mode 100644 tests/outputs/fully-featured.rst create mode 100644 tests/outputs/mostly-featured.rst create mode 100644 tests/outputs/pruned.yaml create mode 100644 tests/test_integ.py diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..15357ba --- /dev/null +++ b/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +markers = + integtest: mark a test as an integration test. diff --git a/src/brassy/templates/release_yaml_template.py b/src/brassy/templates/release_yaml_template.py index 1794353..b5d613c 100644 --- a/src/brassy/templates/release_yaml_template.py +++ b/src/brassy/templates/release_yaml_template.py @@ -2,6 +2,8 @@ from typing import List, Optional, Dict from datetime import date as Date +import dateparser + from pydantic import ( BaseModel, HttpUrl, @@ -10,6 +12,7 @@ RootModel, Field, field_validator, + validator, ) @@ -45,12 +48,31 @@ class DateRange(BaseModel): start: Optional[Date] finish: Optional[Date] + @validator("start", "finish", pre=True, always=True) + def parse_date(cls, value): + if value is None or isinstance(value, Date): + return value + if isinstance(value, str): + value = value.strip() + if not value or value.lower() in ["never", "null"]: + return None + try: + parsed = dateparser.parse(value) + if parsed is None: + raise ValueError(f"Unable to parse date string: {value}") + return parsed.date() + except Exception as e: + raise ValueError(f"Invalid date format: {value}") from e + raise ValueError(f"Invalid type for date field: {value}") + class ChangeItem(BaseModel): title: str description: str files: Files - related_issue: Optional[RelatedIssue] = Field(alias="related-issue") + related_issue: Optional[RelatedIssue] = Field( + alias="related-issue", exclude_unset=True, default=None + ) date: Optional[DateRange] = None diff --git a/tests/inputs/barebones.yaml b/tests/inputs/barebones.yaml new file mode 100644 index 0000000..96f7834 --- /dev/null +++ b/tests/inputs/barebones.yaml @@ -0,0 +1,6 @@ +bug fix: +- title: Test bug fix. + description: 'This fixes all computer bugs ever written.' + files: + moved: + - linux/src diff --git a/tests/inputs/fully-featured.yaml b/tests/inputs/fully-featured.yaml new file mode 100644 index 0000000..d6b6fb4 --- /dev/null +++ b/tests/inputs/fully-featured.yaml @@ -0,0 +1,141 @@ +bug fix: +- title: "Fixed Aang's Avatar State Ⓐ" + description: | + Resolved an issue where Aang could not exit the Avatar State after consuming cactus juice. This caused unintended behavior and prevented progression in the story. + files: + deleted: + - '' + moved: + - 'src/characters/aang_temp.py:src/characters/aang.py' + added: + - '' + modified: + - 'src/avatar/avatar_state_manager.py' + related-issue: + number: 1001 + repo_url: 'https://github.com/AvatarProject/AvatarRepo/issues/1001' + date: + start: '2023/01/01' + finish: '2023-01-05T23:59:59Z' + +enhancement: +- title: 'Implemented Multi-Element Bending for Avatars' + description: | + Avatars can now bend multiple elements simultaneously, allowing for more complex combat strategies. + files: + deleted: + - '' + moved: + - '' + added: + - 'src/bending/multi_element.py' + modified: + - 'src/avatar/avatar_core.py' + - 'src/bending/bending_manager.py' + related-issue: + number: '1000000000000000000000000000000000000000000000' + repo_url: 'https://github.com/AvatarProject/AvatarRepo/issues/1000000000000000000000000000000000000000000000' + date: + start: '2023-03-01T00:00:00' + finish: '2023-03-10T23:59:59Z' + +deprecation: +- title: 'Deprecated Old Bending Stances' + description: | + The classic bending stances are deprecated in favor of dynamic stances that adapt to the situation. + files: + deleted: + - '' + moved: + - '' + added: + - '' + modified: + - 'assets/animations/stances/*' + related-issue: + number: null + repo_url: '' + date: + start: 'Yesterday' + finish: 'Today' + +removal: +- title: 'Removed Unagi Sea Serpent from Kyoshi Island' + description: | + The Unagi has been removed due to community feedback regarding difficulty levels. + files: + deleted: + - 'assets/creatures/unagi.obj' + - 'src/creatures/unagi_behavior.py' + moved: + - '' + added: + - '' + modified: + - 'src/locations/kyoshi_island.py' + related-issue: + number: '1005' + repo_url: 'https://github.com/AvatarProject/AvatarRepo/' + date: + start: '2023-05-01' + finish: 'Never' + +performance: +- title: 'Optimized Fire Nation Ship Rendering' + description: | + Improved rendering performance for Fire Nation ships by 50% by reducing polygon count and optimizing textures. + files: + deleted: + - '' + moved: + - '' + added: + - '' + modified: + - 'assets/vehicles/fire_nation_ship.obj' + related-issue: + number: 1006 + repo_url: 'https://github.com/AvatarProject/AvatarRepo/issues/1006' + date: + start: '2023-07-01' + finish: '2023-07-15' + +documentation: +- title: 'Added Documentation for Combustion Bending' + description: | + New documentation explains the mechanics and limitations of combustion bending. + files: + deleted: + - '' + moved: + - '' + added: + - 'docs/bending/combustion_bending.md' + modified: + - '' + related-issue: + number: 1008 + repo_url: 'https://github.com/AvatarProject/AvatarRepo/issues/1008' + date: + start: '2023-08-05' + finish: '2023-08-10' + +continuous integration: +- title: 'Implemented Nightly Builds for the Fire Nation Branch' + description: | + Set up nightly builds and tests for the Fire Nation development branch to ensure stability. + files: + deleted: + - '' + moved: + - '' + added: + - '.github/workflows/nightly_fire_nation.yml' + modified: + - '' + related-issue: + number: 1009 + repo_url: 'https://github.com/AvatarProject/AvatarRepo/issues/1009' + date: + start: '2023-09-01' + finish: '2023-09-02' \ No newline at end of file diff --git a/tests/inputs/mostly-featured.yaml b/tests/inputs/mostly-featured.yaml new file mode 100644 index 0000000..1925357 --- /dev/null +++ b/tests/inputs/mostly-featured.yaml @@ -0,0 +1,123 @@ +bug fix: + - title: 'Fixed Bubble Blowing Glitch' + description: | + Resolved an issue where bubble shapes would not form correctly when using the Bubble Blowing Wand. + files: + deleted: [] + moved: [] + added: [] + modified: + - 'src/bubble_wand.py' + related-issue: + number: 101 + repo_url: 'https://github.com/spongebob-app/bubble-wand/issues/101' + date: + start: '2024-03-15' + finish: '2024-03-16' + +enhancement: + - title: 'Added Krabby Patty Secret Formula Encryption' + description: | + Implemented advanced encryption for the Krabby Patty secret formula to enhance security. + files: + deleted: [] + moved: [] + added: + - 'src/secret_formula_encryption.py' + modified: + - 'src/krusty_krab_menu.py' + related-issue: + number: 202 + repo_url: 'https://github.com/spongebob-app/krusty-krab/issues/202' + date: + start: '2024-04-01' + finish: '2024-04-10' + +deprecation: + - title: 'Deprecated Old Jellyfish Net API' + description: | + The old Jellyfish Net API is now deprecated in favor of the new Electric Jellyfish Net API. + files: + deleted: [] + moved: [] + added: [] + modified: + - 'src/jellyfish_net_v1.py' + related-issue: + number: 303 + repo_url: 'https://github.com/spongebob-app/jellyfish-net/issues/303' + date: + start: '2024-05-01' + finish: '2024-05-05' + +removal: + - title: 'Removed Rock Bottom Map Support' + description: | + Dropped support for the Rock Bottom map due to low user engagement and maintenance overhead. + files: + deleted: + - 'maps/rock_bottom_map.py' + moved: [] + added: [] + modified: + - 'src/map_loader.py' + related-issue: + number: 404 + repo_url: 'https://github.com/spongebob-app/maps/issues/404' + date: + start: '2024-06-10' + finish: '2024-06-15' + +performance: + - title: 'Optimized Patricks Rock Loading Time' + description: | + Improved the loading time for Patrick's Rock environment by 60% through asset optimization. + files: + deleted: [] + moved: [] + added: [] + modified: + - 'assets/patricks_rock/*' + related-issue: + number: 505 + repo_url: 'https://github.com/spongebob-app/environments/issues/505' + date: + start: '2024-07-01' + finish: '2024-07-05' + +documentation: + - title: 'Updated Mermaid Man and Barnacle Boy Mission Logs' + description: | + Added new entries and corrected errors in the mission logs for better clarity and accuracy. + files: + deleted: [] + moved: [] + added: + - 'docs/mission_logs/mission_99.md' + modified: + - 'docs/mission_logs/index.md' + related-issue: + number: 606 + repo_url: 'https://github.com/spongebob-app/docs/issues/606' + date: + start: '2024-08-01' + finish: '2024-08-02' + +continuous integration: + - title: 'Implemented Jellyfish Fields CI/CD Pipeline' + description: | + Set up CI/CD pipeline using Jenkins for automated testing and deployment of the Jellyfish Fields module. + files: + deleted: [] + moved: [] + added: + - 'ci/jenkinsfile' + modified: + - 'ci/config.yml' + related-issue: + number: 707 + repo_url: 'https://github.com/spongebob-app/ci/issues/707' + date: + start: '2024-09-01' + finish: '2024-09-03' + diff --git a/tests/inputs/to-prune.yaml b/tests/inputs/to-prune.yaml new file mode 100644 index 0000000..1925357 --- /dev/null +++ b/tests/inputs/to-prune.yaml @@ -0,0 +1,123 @@ +bug fix: + - title: 'Fixed Bubble Blowing Glitch' + description: | + Resolved an issue where bubble shapes would not form correctly when using the Bubble Blowing Wand. + files: + deleted: [] + moved: [] + added: [] + modified: + - 'src/bubble_wand.py' + related-issue: + number: 101 + repo_url: 'https://github.com/spongebob-app/bubble-wand/issues/101' + date: + start: '2024-03-15' + finish: '2024-03-16' + +enhancement: + - title: 'Added Krabby Patty Secret Formula Encryption' + description: | + Implemented advanced encryption for the Krabby Patty secret formula to enhance security. + files: + deleted: [] + moved: [] + added: + - 'src/secret_formula_encryption.py' + modified: + - 'src/krusty_krab_menu.py' + related-issue: + number: 202 + repo_url: 'https://github.com/spongebob-app/krusty-krab/issues/202' + date: + start: '2024-04-01' + finish: '2024-04-10' + +deprecation: + - title: 'Deprecated Old Jellyfish Net API' + description: | + The old Jellyfish Net API is now deprecated in favor of the new Electric Jellyfish Net API. + files: + deleted: [] + moved: [] + added: [] + modified: + - 'src/jellyfish_net_v1.py' + related-issue: + number: 303 + repo_url: 'https://github.com/spongebob-app/jellyfish-net/issues/303' + date: + start: '2024-05-01' + finish: '2024-05-05' + +removal: + - title: 'Removed Rock Bottom Map Support' + description: | + Dropped support for the Rock Bottom map due to low user engagement and maintenance overhead. + files: + deleted: + - 'maps/rock_bottom_map.py' + moved: [] + added: [] + modified: + - 'src/map_loader.py' + related-issue: + number: 404 + repo_url: 'https://github.com/spongebob-app/maps/issues/404' + date: + start: '2024-06-10' + finish: '2024-06-15' + +performance: + - title: 'Optimized Patricks Rock Loading Time' + description: | + Improved the loading time for Patrick's Rock environment by 60% through asset optimization. + files: + deleted: [] + moved: [] + added: [] + modified: + - 'assets/patricks_rock/*' + related-issue: + number: 505 + repo_url: 'https://github.com/spongebob-app/environments/issues/505' + date: + start: '2024-07-01' + finish: '2024-07-05' + +documentation: + - title: 'Updated Mermaid Man and Barnacle Boy Mission Logs' + description: | + Added new entries and corrected errors in the mission logs for better clarity and accuracy. + files: + deleted: [] + moved: [] + added: + - 'docs/mission_logs/mission_99.md' + modified: + - 'docs/mission_logs/index.md' + related-issue: + number: 606 + repo_url: 'https://github.com/spongebob-app/docs/issues/606' + date: + start: '2024-08-01' + finish: '2024-08-02' + +continuous integration: + - title: 'Implemented Jellyfish Fields CI/CD Pipeline' + description: | + Set up CI/CD pipeline using Jenkins for automated testing and deployment of the Jellyfish Fields module. + files: + deleted: [] + moved: [] + added: + - 'ci/jenkinsfile' + modified: + - 'ci/config.yml' + related-issue: + number: 707 + repo_url: 'https://github.com/spongebob-app/ci/issues/707' + date: + start: '2024-09-01' + finish: '2024-09-03' + diff --git a/tests/outputs/barebones.rst b/tests/outputs/barebones.rst new file mode 100644 index 0000000..2ad1565 --- /dev/null +++ b/tests/outputs/barebones.rst @@ -0,0 +1,16 @@ +Version [UNKNOWN] (2024-10-14) +****************************** + + * *Bug fix*: Test bug fix. + +Bug fix +======= + +Test bug fix. +------------- + +This fixes all computer bugs ever written. + +:: + + moved: linux/src diff --git a/tests/outputs/fully-featured.rst b/tests/outputs/fully-featured.rst new file mode 100644 index 0000000..4908969 --- /dev/null +++ b/tests/outputs/fully-featured.rst @@ -0,0 +1,103 @@ +Version [UNKNOWN] (2024-10-14) +****************************** + + * *Bug fix*: Fixed Aang's Avatar State Ⓐ + * *Enhancement*: Implemented Multi-Element Bending for Avatars + * *Deprecation*: Deprecated Old Bending Stances + * *Removal*: Removed Unagi Sea Serpent from Kyoshi Island + * *Performance*: Optimized Fire Nation Ship Rendering + * *Documentation*: Added Documentation for Combustion Bending + * *Continuous integration*: Implemented Nightly Builds for the Fire Nation Branch + +Bug fix +======= + +Fixed Aang's Avatar State Ⓐ +--------------------------- + +Resolved an issue where Aang could not exit the Avatar State after consuming cactus juice. This caused unintended behavior and prevented progression in the story. + + +:: + + moved: src/characters/aang_temp.py:src/characters/aang.py + modified: src/avatar/avatar_state_manager.py + +Enhancement +=========== + +Implemented Multi-Element Bending for Avatars +--------------------------------------------- + +Avatars can now bend multiple elements simultaneously, allowing for more complex combat strategies. + + +:: + + added: src/bending/multi_element.py + +Deprecation +=========== + +Deprecated Old Bending Stances +------------------------------ + +The classic bending stances are deprecated in favor of dynamic stances that adapt to the situation. + + +:: + + modified: assets/animations/stances/* + +Removal +======= + +Removed Unagi Sea Serpent from Kyoshi Island +-------------------------------------------- + +The Unagi has been removed due to community feedback regarding difficulty levels. + + +:: + + deleted: assets/creatures/unagi.obj + deleted: src/creatures/unagi_behavior.py + +Performance +=========== + +Optimized Fire Nation Ship Rendering +------------------------------------ + +Improved rendering performance for Fire Nation ships by 50% by reducing polygon count and optimizing textures. + + +:: + + modified: assets/vehicles/fire_nation_ship.obj + +Documentation +============= + +Added Documentation for Combustion Bending +------------------------------------------ + +New documentation explains the mechanics and limitations of combustion bending. + + +:: + + added: docs/bending/combustion_bending.md + +Continuous integration +====================== + +Implemented Nightly Builds for the Fire Nation Branch +----------------------------------------------------- + +Set up nightly builds and tests for the Fire Nation development branch to ensure stability. + + +:: + + added: .github/workflows/nightly_fire_nation.yml diff --git a/tests/outputs/mostly-featured.rst b/tests/outputs/mostly-featured.rst new file mode 100644 index 0000000..f50a5d0 --- /dev/null +++ b/tests/outputs/mostly-featured.rst @@ -0,0 +1,105 @@ +Version [UNKNOWN] (2024-10-14) +****************************** + + * *Bug fix*: Fixed Bubble Blowing Glitch + * *Enhancement*: Added Krabby Patty Secret Formula Encryption + * *Deprecation*: Deprecated Old Jellyfish Net API + * *Removal*: Removed Rock Bottom Map Support + * *Performance*: Optimized Patricks Rock Loading Time + * *Documentation*: Updated Mermaid Man and Barnacle Boy Mission Logs + * *Continuous integration*: Implemented Jellyfish Fields CI/CD Pipeline + +Bug fix +======= + +Fixed Bubble Blowing Glitch +--------------------------- + +Resolved an issue where bubble shapes would not form correctly when using the Bubble Blowing Wand. + + +:: + + modified: src/bubble_wand.py + +Enhancement +=========== + +Added Krabby Patty Secret Formula Encryption +-------------------------------------------- + +Implemented advanced encryption for the Krabby Patty secret formula to enhance security. + + +:: + + added: src/secret_formula_encryption.py + modified: src/krusty_krab_menu.py + +Deprecation +=========== + +Deprecated Old Jellyfish Net API +-------------------------------- + +The old Jellyfish Net API is now deprecated in favor of the new Electric Jellyfish Net API. + + +:: + + modified: src/jellyfish_net_v1.py + +Removal +======= + +Removed Rock Bottom Map Support +------------------------------- + +Dropped support for the Rock Bottom map due to low user engagement and maintenance overhead. + + +:: + + deleted: maps/rock_bottom_map.py + modified: src/map_loader.py + +Performance +=========== + +Optimized Patricks Rock Loading Time +------------------------------------ + +Improved the loading time for Patrick's Rock environment by 60% through asset optimization. + + +:: + + modified: assets/patricks_rock/* + +Documentation +============= + +Updated Mermaid Man and Barnacle Boy Mission Logs +------------------------------------------------- + +Added new entries and corrected errors in the mission logs for better clarity and accuracy. + + +:: + + added: docs/mission_logs/mission_99.md + modified: docs/mission_logs/index.md + +Continuous integration +====================== + +Implemented Jellyfish Fields CI/CD Pipeline +------------------------------------------- + +Set up CI/CD pipeline using Jenkins for automated testing and deployment of the Jellyfish Fields module. + + +:: + + added: ci/jenkinsfile + modified: ci/config.yml diff --git a/tests/outputs/pruned.yaml b/tests/outputs/pruned.yaml new file mode 100644 index 0000000..8572e9f --- /dev/null +++ b/tests/outputs/pruned.yaml @@ -0,0 +1,113 @@ +bug fix: +- title: Fixed Bubble Blowing Glitch + description: 'Resolved an issue where bubble shapes would not form correctly when + using the Bubble Blowing Wand. + + ' + files: + modified: + - src/bubble_wand.py + related-issue: + number: 101 + repo_url: https://github.com/spongebob-app/bubble-wand/issues/101 + date: + start: '2024-03-15' + finish: '2024-03-16' +enhancement: +- title: Added Krabby Patty Secret Formula Encryption + description: 'Implemented advanced encryption for the Krabby Patty secret formula + to enhance security. + + ' + files: + added: + - src/secret_formula_encryption.py + modified: + - src/krusty_krab_menu.py + related-issue: + number: 202 + repo_url: https://github.com/spongebob-app/krusty-krab/issues/202 + date: + start: '2024-04-01' + finish: '2024-04-10' +deprecation: +- title: Deprecated Old Jellyfish Net API + description: 'The old Jellyfish Net API is now deprecated in favor of the new Electric + Jellyfish Net API. + + ' + files: + modified: + - src/jellyfish_net_v1.py + related-issue: + number: 303 + repo_url: https://github.com/spongebob-app/jellyfish-net/issues/303 + date: + start: '2024-05-01' + finish: '2024-05-05' +removal: +- title: Removed Rock Bottom Map Support + description: 'Dropped support for the Rock Bottom map due to low user engagement + and maintenance overhead. + + ' + files: + deleted: + - maps/rock_bottom_map.py + modified: + - src/map_loader.py + related-issue: + number: 404 + repo_url: https://github.com/spongebob-app/maps/issues/404 + date: + start: '2024-06-10' + finish: '2024-06-15' +performance: +- title: Optimized Patricks Rock Loading Time + description: 'Improved the loading time for Patrick''s Rock environment by 60% through + asset optimization. + + ' + files: + modified: + - assets/patricks_rock/* + related-issue: + number: 505 + repo_url: https://github.com/spongebob-app/environments/issues/505 + date: + start: '2024-07-01' + finish: '2024-07-05' +documentation: +- title: Updated Mermaid Man and Barnacle Boy Mission Logs + description: 'Added new entries and corrected errors in the mission logs for better + clarity and accuracy. + + ' + files: + added: + - docs/mission_logs/mission_99.md + modified: + - docs/mission_logs/index.md + related-issue: + number: 606 + repo_url: https://github.com/spongebob-app/docs/issues/606 + date: + start: '2024-08-01' + finish: '2024-08-02' +continuous integration: +- title: Implemented Jellyfish Fields CI/CD Pipeline + description: 'Set up CI/CD pipeline using Jenkins for automated testing and deployment + of the Jellyfish Fields module. + + ' + files: + added: + - ci/jenkinsfile + modified: + - ci/config.yml + related-issue: + number: 707 + repo_url: https://github.com/spongebob-app/ci/issues/707 + date: + start: '2024-09-01' + finish: '2024-09-03' diff --git a/tests/test_integ.py b/tests/test_integ.py new file mode 100644 index 0000000..9b92ae3 --- /dev/null +++ b/tests/test_integ.py @@ -0,0 +1,52 @@ +import subprocess +import tempfile +import shutil +import os + +import pytest + + +def run_cli_command_return_true_if_command_returns_zero(command): + result = subprocess.run(command, capture_output=True, text=True) + assert ( + result.returncode == 0 + ), f"Command failed with return code {result.returncode}" + + +@pytest.mark.integtest +def test_help(monkeypatch): + run_cli_command_return_true_if_command_returns_zero(["brassy", "-h"]) + + +@pytest.mark.integtest +@pytest.mark.parametrize( + "input_file", ["barebones", "mostly-featured", "fully-featured"] +) +def test_build_on_test_files(input_file): + with tempfile.TemporaryDirectory() as output_file_dir: + output_file = os.path.join(output_file_dir, input_file + ".rst") + print(output_file) + run_cli_command_return_true_if_command_returns_zero( + [ + "brassy", + f"./tests/inputs/{input_file}.yaml", + "--output-file", + output_file, + ] + ) + assert [row for row in open(output_file)] == [ + row for row in open(f"./tests/outputs/{input_file}.rst") + ] + + +def test_pruning(): + with tempfile.TemporaryDirectory() as output_file_dir: + to_prune = os.path.join(output_file_dir, "to-prune.yaml") + shutil.copyfile(f"./tests/inputs/to-prune.yaml", to_prune) + + run_cli_command_return_true_if_command_returns_zero( + ["brassy", "--prune", to_prune] + ) + assert [row for row in open(to_prune)] == [ + row for row in open("./tests/outputs/pruned.yaml") + ]