|
| 1 | +"""Notice transformer feature tests.""" |
| 2 | + |
| 3 | +from pytest_bdd import ( |
| 4 | + given, |
| 5 | + scenario, |
| 6 | + then, |
| 7 | + when, |
| 8 | +) |
| 9 | + |
| 10 | +from ted_sws.core.model.notice import NoticeStatus, Notice |
| 11 | +from ted_sws.core.model.transform import MappingSuite |
| 12 | +from ted_sws.data_manager.adapters.repository_abc import NoticeRepositoryABC, MappingSuiteRepositoryABC |
| 13 | +from ted_sws.notice_transformer.adapters.rml_mapper import RMLMapperABC |
| 14 | +from ted_sws.notice_transformer.services.notice_transformer import transform_notice, transform_notice_by_id |
| 15 | + |
| 16 | + |
| 17 | +@scenario('test_notice_transformer_with_eform.feature', 'Transform a eForm TED notice') |
| 18 | +def test_transform_a_ted_notice(): |
| 19 | + """Transform a TED notice.""" |
| 20 | + |
| 21 | + |
| 22 | +@given('a mapping suite package') |
| 23 | +def a_mapping_suite_package(eform_mapping_suite): |
| 24 | + """a mapping suite package.""" |
| 25 | + assert eform_mapping_suite |
| 26 | + assert isinstance(eform_mapping_suite, MappingSuite) |
| 27 | + |
| 28 | + |
| 29 | +@given('a eForm notice', target_fixture="eligible_for_transformation_eForm_notice") |
| 30 | +def a_notice(eform_transformation_eligible_notice): |
| 31 | + """a notice.""" |
| 32 | + assert eform_transformation_eligible_notice |
| 33 | + assert isinstance(eform_transformation_eligible_notice, Notice) |
| 34 | + return eform_transformation_eligible_notice |
| 35 | + |
| 36 | + |
| 37 | +@given('a rml mapper') |
| 38 | +def a_rml_mapper(rml_mapper): |
| 39 | + """a rml mapper.""" |
| 40 | + assert rml_mapper |
| 41 | + assert isinstance(rml_mapper, RMLMapperABC) |
| 42 | + |
| 43 | + |
| 44 | +@given('given mapping suite is eligible for notice transformation') |
| 45 | +def given_mapping_suite_is_eligible_for_notice_transformation(): |
| 46 | + """given mapping suite is eligible for notice transformation.""" |
| 47 | + |
| 48 | + |
| 49 | +@given('given notice is eligible for transformation') |
| 50 | +def given_notice_is_eligible_for_transformation(eligible_for_transformation_eForm_notice): |
| 51 | + """given notice is eligible for transformation.""" |
| 52 | + assert eligible_for_transformation_eForm_notice |
| 53 | + assert eligible_for_transformation_eForm_notice.status == NoticeStatus.PREPROCESSED_FOR_TRANSFORMATION |
| 54 | + |
| 55 | + |
| 56 | +@when('the notice transformation is executed', target_fixture="transformed_notice") |
| 57 | +def the_notice_transformation_is_executed(eligible_for_transformation_eForm_notice, mapping_suite, rml_mapper): |
| 58 | + """the notice transformation is executed.""" |
| 59 | + transformed_notice = transform_notice(notice=eligible_for_transformation_eForm_notice, mapping_suite=mapping_suite, |
| 60 | + rml_mapper=rml_mapper) |
| 61 | + return transformed_notice |
| 62 | + |
| 63 | + |
| 64 | +@then('the notice has RDF manifestation') |
| 65 | +def the_notice_have_rdf_manifestation(transformed_notice: Notice): |
| 66 | + """the notice have RDF manifestation.""" |
| 67 | + assert transformed_notice.rdf_manifestation |
| 68 | + assert transformed_notice.rdf_manifestation.object_data |
| 69 | + |
| 70 | + |
| 71 | +@then('the notice status is TRANSFORMED') |
| 72 | +def the_notice_status_is_transformed(transformed_notice: Notice): |
| 73 | + """the notice status is TRANSFORMED.""" |
| 74 | + assert transformed_notice.status == NoticeStatus.TRANSFORMED |
0 commit comments