Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CaptainOfHacks committed Feb 13, 2024
1 parent 5636c54 commit 2b0f0d8
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 165 deletions.
6 changes: 6 additions & 0 deletions ted_sws/notice_fetcher/adapters/ted_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,17 @@ def get_generator_by_query(self, query: dict, result_fields: dict = None) -> Gen
documents_content += response_body[RESPONSE_RESULTS]
for document_content in documents_content:
document_content[DOCUMENT_CONTENT] = self._retrieve_document_content(document_content)
document_id = document_content[DOCUMENT_NOTICE_ID_KEY]
document_id = "0" * (11 - len(document_id)) + document_id
document_content[DOCUMENT_NOTICE_ID_KEY] = document_id
del document_content[LINKS_TO_CONTENT_KEY]
yield document_content
else:
for document_content in documents_content:
document_content[DOCUMENT_CONTENT] = self._retrieve_document_content(document_content)
document_id = document_content[DOCUMENT_NOTICE_ID_KEY]
document_id = "0" * (11 - len(document_id)) + document_id
document_content[DOCUMENT_NOTICE_ID_KEY] = document_id
del document_content[LINKS_TO_CONTENT_KEY]
yield document_content

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,12 @@ def _test_generate_eforms_sample_dataset(ted_document_search):
results_dir_path.mkdir(parents=True, exist_ok=True)
result_notice_xml_path = results_dir_path / f"{notice['ND']}.xml"
result_notice_xml_path.write_text(notice["content"], encoding="utf-8")


def test_fetch_notice_by_id(ted_document_search):
notice_id = "067623-2022"
import json
notice_content = ted_document_search.get_by_id(document_id=notice_id)
result_notice_path = pathlib.Path(__file__).parent / "epo_notice.xml"
result_notice_path.write_text(json.dumps(notice_content), encoding="utf-8")

Loading

0 comments on commit 2b0f0d8

Please sign in to comment.