Skip to content

Commit 32b3cb6

Browse files
Create test_notice_extractor.py
1 parent 444ff73 commit 32b3cb6

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from pytest_bdd import scenario, given, when, then, parsers
2+
3+
from ted_sws.notice_metadata_processor.model.metadata import ExtractedMetadata
4+
from ted_sws.notice_metadata_processor.services.xml_manifestation_metadata_extractor import XMLManifestationMetadataExtractor
5+
from ted_sws.notice_fetcher.adapters.ted_api import TedRequestAPI, TedAPIAdapter
6+
from ted_sws.notice_fetcher.services.notice_fetcher import NoticeFetcher
7+
8+
9+
@scenario('notice_extractor.feature', 'Extracting metadata')
10+
def test_extract_metadata():
11+
"""Extracting metadata"""
12+
13+
14+
@given("an XML manifestation", target_fixture="xml_manifestation")
15+
def step_impl(notice_identifier, api_end_point, fake_notice_storage):
16+
NoticeFetcher(notice_repository=fake_notice_storage,
17+
ted_api_adapter=TedAPIAdapter(request_api=TedRequestAPI(),
18+
ted_api_url=api_end_point)).fetch_notice_by_id(
19+
document_id=notice_identifier)
20+
return fake_notice_storage.get(reference=notice_identifier).xml_manifestation
21+
22+
23+
@when("the extracting process is executed", target_fixture="extracted_metadata")
24+
def step_impl(xml_manifestation):
25+
return XMLManifestationMetadataExtractor(xml_manifestation=xml_manifestation).to_metadata()
26+
27+
28+
@then(parsers.parse("extracted {metadata} is possibly available"))
29+
def step_impl(extracted_metadata, notice_identifier, metadata):
30+
assert isinstance(extracted_metadata, ExtractedMetadata)
31+
assert extracted_metadata.dict().keys() == ExtractedMetadata.__fields__.keys()
32+
assert notice_identifier == extracted_metadata.dict()["notice_publication_number"]
33+
assert metadata in extracted_metadata.dict()

0 commit comments

Comments
 (0)