From 8d82f8c6257e86cca338dc8ab5a08f44467c991f Mon Sep 17 00:00:00 2001 From: Takahiro Mitsui Date: Thu, 19 Oct 2023 14:01:43 +0200 Subject: [PATCH] feat: Update README --- README-feature/impl-factory_pattern_repos.md | 27 ++++++++++++++++++-- tests/conftest.py | 1 + tests/e2e/api/versions/test_plugin.py | 4 +++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/README-feature/impl-factory_pattern_repos.md b/README-feature/impl-factory_pattern_repos.md index 04e790ff..a8fcc732 100644 --- a/README-feature/impl-factory_pattern_repos.md +++ b/README-feature/impl-factory_pattern_repos.md @@ -1,3 +1,26 @@ -6f246d4 (HEAD -> feature/impl-factory_pattern_repos, origin/feature/impl-factory_pattern_repos) feat: Replace with repo +# Implementation of the Factory Pattern for repositories + +## Here is what I have done + +- Implemented the factory pattern for repositories (party_donation, party). +- Implemented e2e testing routes (**/v1/partydonations**, **/plugin/partydonations**, **/plugin/parties**). +- Refactored existing functions to fetch data for the routes with the repository factories. + +## Description + +I implemented the factory_pattern to handle multiple repositories. As long as unit tests, I wrote e2e tests for existing party donation-related routes. After checking the tests, I refactored the existing functions to fetch data (e.g., get_all_party_donations, get_parties) with repository factories. + +(Before refactoring: partydonations) e30a345 feat: Test plugin party_donation endpoint -95bf7c8 feat: Test pary_donation_v1 endpoint by postgres \ No newline at end of file +95bf7c8 feat: Test pary_donation_v1 endpoint by postgres +a5b23ea feat: Set up env for testing + +(After refactoring: partydonations) +6f246d4 feat: Replace with repo + +(Before refactoring: parties) +0f0c8da feat: Restructure e2e testing +5450de6 feat: Test parties endpoint + +(After refactoring: parties) +ba30cd7 feat: Replace with repo diff --git a/tests/conftest.py b/tests/conftest.py index 1f352ab5..7f5de2bd 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -90,6 +90,7 @@ def postgres_session(postgres_db): # Arrange @pytest.fixture def setup_postgres_party_related_tables(postgres_session): + """Create a postgres session with party related tables for testing.""" # PartyStyle party_style_data = [ (1, "CDU", "#000000", "#FFFFFF", "#000000"), diff --git a/tests/e2e/api/versions/test_plugin.py b/tests/e2e/api/versions/test_plugin.py index 84ac9b7b..53268686 100644 --- a/tests/e2e/api/versions/test_plugin.py +++ b/tests/e2e/api/versions/test_plugin.py @@ -13,6 +13,7 @@ class TestPartyDonations: def test_get_party_donations_with_party_ids( self, setup_postgres_party_related_tables ): + """Test that the endpoint returns the correct data for the given party ids.""" party_ids = [1, 100] response = client.get( self.endpoint + f"?filters={party_ids[0]}" + f"&filters={party_ids[1]}" @@ -27,6 +28,7 @@ def test_get_party_donations_with_party_ids( def test_get_party_donations_with_invalid_party_id( self, setup_postgres_party_related_tables ): + """Test that the endpoint returns 404 if the party id is invalid.""" party_ids = [100] response = client.get(self.endpoint + f"?filters={party_ids[0]}") # Assert @@ -35,6 +37,7 @@ def test_get_party_donations_with_invalid_party_id( def test_get_party_donations_without_party_ids( self, setup_postgres_party_related_tables ): + """Test that the endpoint returns the correct data.""" party_ids = [1, 100] response = client.get(self.endpoint) # Assert @@ -49,6 +52,7 @@ class TestParty: endpoint = "/plugin/parties" def test_get_parties(self, setup_postgres_party_related_tables): + """Test that the endpoint returns the correct data.""" response = client.get(self.endpoint) # Assert assert response.status_code == 200