Skip to content

Commit

Permalink
feat: Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
takahiromitsui committed Oct 19, 2023
1 parent ba30cd7 commit 8d82f8c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
27 changes: 25 additions & 2 deletions README-feature/impl-factory_pattern_repos.md
Original file line number Diff line number Diff line change
@@ -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
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
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
4 changes: 4 additions & 0 deletions tests/e2e/api/versions/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]}"
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 8d82f8c

Please sign in to comment.