Skip to content

Commit

Permalink
resolve bug
Browse files Browse the repository at this point in the history
  • Loading branch information
duprijil committed Oct 6, 2023
1 parent 095801d commit 70be603
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,12 @@ def update_daily_notices_metadata_from_ted(start_date: date = None,

# Getting from TED API dates that are not in the repository from date range
for day in dates_not_in_repository:
ted_api_query = DAILY_NOTICES_METADATA_TED_API_QUERY
ted_api_query = DAILY_NOTICES_METADATA_TED_API_QUERY.copy()
ted_api_query[TED_API_QUERY_FIELD] = ted_api_query[TED_API_QUERY_FIELD].format(
aggregation_date=day.strftime(TED_API_WILDCARD_DATE_FORMAT))
notice_ids = ted_api.get_by_query(ted_api_query,
result_fields=DAILY_NOTICES_METADATA_TED_API_QUERY_RESULT_FIELDS)
notice_ids = ted_api.get_by_query(ted_api_query, result_fields=DAILY_NOTICES_METADATA_TED_API_QUERY_RESULT_FIELDS)
if not notice_ids:
continue
daily_notices_metadata = DailyNoticesMetadata(aggregation_date=day)
daily_notices_metadata.ted_api_notice_ids = [notice[TED_API_NOTICE_ID_FIELD] for notice in notice_ids]
daily_notices_metadata_repo.add(daily_notices_metadata)
Expand Down
5 changes: 5 additions & 0 deletions tests/e2e/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,8 @@ def fake_notice_repository(fake_mongodb_client):
@pytest.fixture
def example_date():
return date(2021, 1, 7)


@pytest.fixture
def example_date_without_notices():
return date(2021, 1, 9)
14 changes: 11 additions & 3 deletions tests/e2e/supra_notice_manager/test_notices_metadata_services.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
from ted_sws import config
from ted_sws.core.model.supra_notice import DailyNoticesMetadata
from ted_sws.data_manager.adapters.daily_notices_metadata_repository import DailyNoticesMetadataRepository
from ted_sws.supra_notice_manager.services.daily_notices_metadata_services import update_daily_notices_metadata_from_ted, \
update_daily_notices_metadata_with_fetched_data
from ted_sws.notice_fetcher.adapters.ted_api import TedAPIAdapter, TedRequestAPI
from ted_sws.supra_notice_manager.services.daily_notices_metadata_services import \
update_daily_notices_metadata_from_ted, \
update_daily_notices_metadata_with_fetched_data


def test_update_daily_notices_metadata_from_ted(fake_mongodb_client, example_date):
def test_update_daily_notices_metadata_from_ted(fake_mongodb_client, example_date, example_date_without_notices):
"""
Test update_daily_notices_metadata_from_ted function
"""

ted_api = TedAPIAdapter(TedRequestAPI(), config.TED_API_URL)
daily_notices_metadata_repo = DailyNoticesMetadataRepository(fake_mongodb_client)

update_daily_notices_metadata_from_ted(start_date=example_date_without_notices,
end_date=example_date_without_notices,
ted_api=ted_api,
daily_notices_metadata_repo=daily_notices_metadata_repo)

assert len(list(daily_notices_metadata_repo.list())) == 0

update_daily_notices_metadata_from_ted(start_date=example_date,
end_date=example_date,
ted_api=ted_api,
Expand Down

0 comments on commit 70be603

Please sign in to comment.