From ee4404f71ba02fcf363c7808afa81b493e4a27a8 Mon Sep 17 00:00:00 2001 From: Tobias Mikula <72911271+MobiTikula@users.noreply.github.com> Date: Mon, 18 Nov 2024 14:40:41 +0100 Subject: [PATCH 1/2] README.md update plus better error handling for No Topic case. --- README.md | 12 ++++++------ .../model/consolidated_issue.py | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 8a43a49..6c66b96 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ See the default action step definition: "projects-title-filter": ["Community Outreach Initiatives", "CDD Project"] } ]' - ``` +``` See the full example of action step definition (in example are used non-default values): @@ -534,14 +534,14 @@ All done! ✨ 🍰 ✨ ## Run Unit Test Unit tests are written using Pytest framework. To run alle the tests, use the following command: -```bash +```shell pytest tests/ ``` You can modify the directory to control the level of detail or granularity as per your needs. To run specific test, write the command following the pattern below: -```bash +```shell pytest tests/utils/test_utils.py::test_make_issue_key ``` @@ -551,14 +551,14 @@ This project uses [pytest-cov](https://pypi.org/project/pytest-cov/) plugin to g The objective of the project is to achieve a minimal score of 80 %. We do exclude the `tests/` file from the coverage report. To generate the coverage report, run the following command: -```bash +```shell pytest --cov=. tests/ --cov-fail-under=80 --cov-report=html ``` See the coverage report on the path: -``` -htmlcov/index.html +```shell +open htmlcov/index.html ``` ## Deployment diff --git a/living_documentation_generator/model/consolidated_issue.py b/living_documentation_generator/model/consolidated_issue.py index d5a5592..b5cbf14 100644 --- a/living_documentation_generator/model/consolidated_issue.py +++ b/living_documentation_generator/model/consolidated_issue.py @@ -199,6 +199,7 @@ def generate_directory_path(self, issue_table: str) -> list[str]: # If no label ends with "Topic", create a "NoTopic" issue directory path if not topic_labels: self.__topics = ["NoTopic"] + logger.error("No Topic label found for Issue #%s: %s (%s)", self.number, self.title, self.repository_id) no_topic_path = os.path.join(output_path, "NoTopic") return [no_topic_path] From c795016f0c149d168379f33a42ebba7570d221c2 Mon Sep 17 00:00:00 2001 From: Tobias Mikula <72911271+MobiTikula@users.noreply.github.com> Date: Tue, 19 Nov 2024 08:57:00 +0100 Subject: [PATCH 2/2] Bug Fix. --- living_documentation_generator/model/consolidated_issue.py | 2 +- tests/model/test_consolidated_issue.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/living_documentation_generator/model/consolidated_issue.py b/living_documentation_generator/model/consolidated_issue.py index b5cbf14..f0ea63f 100644 --- a/living_documentation_generator/model/consolidated_issue.py +++ b/living_documentation_generator/model/consolidated_issue.py @@ -199,7 +199,7 @@ def generate_directory_path(self, issue_table: str) -> list[str]: # If no label ends with "Topic", create a "NoTopic" issue directory path if not topic_labels: self.__topics = ["NoTopic"] - logger.error("No Topic label found for Issue #%s: %s (%s)", self.number, self.title, self.repository_id) + logger.error("No Topic label found for Issue #%i: %s (%s)", self.number, self.title, self.repository_id) no_topic_path = os.path.join(output_path, "NoTopic") return [no_topic_path] diff --git a/tests/model/test_consolidated_issue.py b/tests/model/test_consolidated_issue.py index 599cbb9..d56f990 100644 --- a/tests/model/test_consolidated_issue.py +++ b/tests/model/test_consolidated_issue.py @@ -118,6 +118,7 @@ def test_generate_directory_path_structured_output_disabled_grouping_by_topics_e def test_generate_directory_path_structured_output_disabled_grouping_by_topics_enabled_no_issue_topics(mocker): + mock_log_error = mocker.patch("living_documentation_generator.model.consolidated_issue.logger.error") mock_log_debug = mocker.patch("living_documentation_generator.model.consolidated_issue.logger.debug") mocker.patch( "living_documentation_generator.action_inputs.ActionInputs.get_output_directory", @@ -135,6 +136,9 @@ def test_generate_directory_path_structured_output_disabled_grouping_by_topics_e actual = consolidated_issue.generate_directory_path("| Labels | feature, bug |") assert ["/base/output/path/NoTopic"] == actual + mock_log_error.assert_called_once_with( + "No Topic label found for Issue #%i: %s (%s)", 1, "Issue Title", "organization/repository" + ) mock_log_debug.assert_not_called()