-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #535 from OP-TED/feature/TED4-160
- Loading branch information
Showing
10 changed files
with
268 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
tests/features/notice_metadata_processor/metadata_normaliser_eforms.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Feature: Notice metadata normaliser for eForms | ||
A fetched eForm notice metadata should be normalised | ||
|
||
Scenario Outline: Normalising notice metadata for an eForm | ||
Given a eForm notice | ||
When the normalise process is executed | ||
Then a normalised notice <metadata> is <possibly> available | ||
And the notice status is NORMALISED_METADATA | ||
And normalised metadata is available | ||
|
||
Examples: | ||
| metadata | possibly | | ||
| title | True | | ||
| long_title | True | | ||
| notice_publication_number | True | | ||
| publication_date | True | | ||
| ojs_issue_number | True | | ||
| ojs_type | True | | ||
| eforms_subtype | True | | ||
| xsd_version | False | | ||
| original_language | False | | ||
| eform_sdk_version | True | | ||
| notice_source | True | | ||
| document_sent_date | True | | ||
| deadline_for_submission | False | | ||
| notice_type | True | | ||
| form_type | True | | ||
| place_of_performance | True | | ||
| legal_basis_directive | True | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
tests/features/notice_metadata_processor/test_eForm_notice_eligibility.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Feature: Notice metadata processor for Eforms | ||
The system is able to process TED notice metadata and check eligibility with mapping rules. | ||
|
||
Scenario: Notice eligibility checking for eForms | ||
Given a notice | ||
And the notice has eforms subtype 16 and sdk version 1.7 | ||
And the notice status is NORMALISED | ||
And a mapping suite repository | ||
And a mapping suite for eforms subtype 16 and sdk version 1.7 is available in mapping suite repository | ||
When the notice eligibility checking is executed | ||
Then the notice status is ELIGIBLE_FOR_TRANSFORMATION |
68 changes: 68 additions & 0 deletions
68
tests/features/notice_metadata_processor/test_eForm_notice_eligibility.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
"""Notice metadata processor feature tests.""" | ||
|
||
from pytest_bdd import ( | ||
given, | ||
scenario, | ||
then, | ||
when, | ||
) | ||
|
||
from ted_sws.core.model.notice import Notice, NoticeStatus | ||
from ted_sws.data_manager.adapters.repository_abc import MappingSuiteRepositoryABC | ||
from ted_sws.notice_metadata_processor.services.notice_eligibility import notice_eligibility_checker | ||
|
||
|
||
@scenario('test_eForm_notice_eligibility.feature', 'Notice eligibility checking for eForms') | ||
def test_notice_eligibility_checking_positive(): | ||
"""Notice eligibility checking positive.""" | ||
|
||
|
||
@given('a mapping suite for eforms subtype 16 and sdk version 1.7 is available in mapping suite repository', target_fixture="mapping_suite_repository") | ||
def a_mapping_suite_for_f03_is_available_in_mapping_suite_repository(clean_mapping_suite_repository, | ||
mapping_suite_repository_with_mapping_suite): | ||
"""a mapping suite for eforms subtype 16 and sdk version 1.7 is available in mapping suite repository.""" | ||
for mapping_suite in mapping_suite_repository_with_mapping_suite.list(): | ||
clean_mapping_suite_repository.add(mapping_suite=mapping_suite) | ||
return clean_mapping_suite_repository | ||
|
||
|
||
|
||
@given('a mapping suite repository') | ||
def a_mapping_suite_repository(clean_mapping_suite_repository): | ||
"""a mapping suite repository.""" | ||
assert clean_mapping_suite_repository | ||
assert isinstance(clean_mapping_suite_repository, MappingSuiteRepositoryABC) | ||
|
||
|
||
@given('a notice') | ||
def a_notice(normalised_eForm_notice): | ||
"""a notice.""" | ||
assert normalised_eForm_notice | ||
assert isinstance(normalised_eForm_notice, Notice) | ||
|
||
|
||
@given('the notice has eforms subtype 16 and sdk version 1.7') | ||
def the_notice_has_eforms_subtype_and_sdk_version(normalised_eForm_notice): | ||
"""the notice has eforms subtype 16 and sdk version 1.7""" | ||
assert normalised_eForm_notice.normalised_metadata.eforms_subtype == "16" | ||
assert normalised_eForm_notice.normalised_metadata.eform_sdk_version == "eforms-sdk-1.7" | ||
|
||
|
||
@given('the notice status is NORMALISED') | ||
def the_notice_status_is_normalised(normalised_eForm_notice): | ||
"""the notice status is NORMALISED.""" | ||
assert normalised_eForm_notice.status == NoticeStatus.NORMALISED_METADATA | ||
|
||
|
||
@when('the notice eligibility checking is executed', target_fixture="checked_notice") | ||
def the_notice_eligibility_checking_is_executed(normalised_eForm_notice, mapping_suite_repository): | ||
"""the notice eligibility checking is executed.""" | ||
notice_eligibility_checker(notice=normalised_eForm_notice, mapping_suite_repository=mapping_suite_repository) | ||
return normalised_eForm_notice | ||
|
||
|
||
@then('the notice status is ELIGIBLE_FOR_TRANSFORMATION') | ||
def the_notice_status_is_eligible_for_transformation(checked_notice: Notice): | ||
"""the notice status is ELIGIBLE_FOR_TRANSFORMATION.""" | ||
assert checked_notice.status == NoticeStatus.ELIGIBLE_FOR_TRANSFORMATION | ||
|
38 changes: 38 additions & 0 deletions
38
tests/features/notice_metadata_processor/test_metadata_normaliser_eforms.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from pytest_bdd import scenario, given, when, then, parsers | ||
|
||
from ted_sws.core.model.notice import NoticeStatus | ||
from ted_sws.notice_metadata_processor.services.metadata_normalizer import normalise_notice | ||
|
||
|
||
@scenario('metadata_normaliser_eforms.feature', 'Normalising notice metadata for an eForm') | ||
def test_normalise_metadata(): | ||
"""normalising metadata""" | ||
|
||
|
||
@given("a eForm notice", target_fixture="notice") | ||
def step_impl(eForm_notice_2023): | ||
return eForm_notice_2023 | ||
|
||
|
||
@when("the normalise process is executed") | ||
def step_impl(notice): | ||
normalise_notice(notice=notice) | ||
|
||
|
||
@then(parsers.parse("a normalised notice {metadata} is {possibly} available")) | ||
def step_impl(notice, metadata, possibly): | ||
metadata_value = notice.normalised_metadata.dict()[metadata] | ||
print(notice.normalised_metadata) | ||
print(metadata) | ||
is_value_there = "True" if metadata_value else "False" | ||
assert is_value_there == possibly | ||
|
||
|
||
@then("the notice status is NORMALISED_METADATA") | ||
def step_impl(notice): | ||
assert notice.status is NoticeStatus.NORMALISED_METADATA | ||
|
||
|
||
@then("normalised metadata is available") | ||
def step_impl(notice): | ||
assert notice.normalised_metadata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
tests/features/notice_transformer/test_notice_transformer_with_eform.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Created by Stefan at 16.08.2022 | ||
Feature: Notice transformer with eForm | ||
The system is able to transform a notice from XML format in RDF format | ||
|
||
Scenario: Transform a eForm TED notice | ||
Given a eForm notice | ||
And a mapping suite package | ||
And a rml mapper | ||
And given notice is eligible for transformation | ||
And given mapping suite is eligible for notice transformation | ||
When the notice transformation is executed | ||
Then the notice has RDF manifestation | ||
And the notice status is TRANSFORMED |
74 changes: 74 additions & 0 deletions
74
tests/features/notice_transformer/test_notice_transformer_with_eform.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
"""Notice transformer feature tests.""" | ||
|
||
from pytest_bdd import ( | ||
given, | ||
scenario, | ||
then, | ||
when, | ||
) | ||
|
||
from ted_sws.core.model.notice import NoticeStatus, Notice | ||
from ted_sws.core.model.transform import MappingSuite | ||
from ted_sws.data_manager.adapters.repository_abc import NoticeRepositoryABC, MappingSuiteRepositoryABC | ||
from ted_sws.notice_transformer.adapters.rml_mapper import RMLMapperABC | ||
from ted_sws.notice_transformer.services.notice_transformer import transform_notice, transform_notice_by_id | ||
|
||
|
||
@scenario('test_notice_transformer_with_eform.feature', 'Transform a eForm TED notice') | ||
def test_transform_a_ted_notice(): | ||
"""Transform a TED notice.""" | ||
|
||
|
||
@given('a mapping suite package') | ||
def a_mapping_suite_package(eform_mapping_suite): | ||
"""a mapping suite package.""" | ||
assert eform_mapping_suite | ||
assert isinstance(eform_mapping_suite, MappingSuite) | ||
|
||
|
||
@given('a eForm notice', target_fixture="eligible_for_transformation_eForm_notice") | ||
def a_notice(eform_transformation_eligible_notice): | ||
"""a notice.""" | ||
assert eform_transformation_eligible_notice | ||
assert isinstance(eform_transformation_eligible_notice, Notice) | ||
return eform_transformation_eligible_notice | ||
|
||
|
||
@given('a rml mapper') | ||
def a_rml_mapper(rml_mapper): | ||
"""a rml mapper.""" | ||
assert rml_mapper | ||
assert isinstance(rml_mapper, RMLMapperABC) | ||
|
||
|
||
@given('given mapping suite is eligible for notice transformation') | ||
def given_mapping_suite_is_eligible_for_notice_transformation(): | ||
"""given mapping suite is eligible for notice transformation.""" | ||
|
||
|
||
@given('given notice is eligible for transformation') | ||
def given_notice_is_eligible_for_transformation(eligible_for_transformation_eForm_notice): | ||
"""given notice is eligible for transformation.""" | ||
assert eligible_for_transformation_eForm_notice | ||
assert eligible_for_transformation_eForm_notice.status == NoticeStatus.PREPROCESSED_FOR_TRANSFORMATION | ||
|
||
|
||
@when('the notice transformation is executed', target_fixture="transformed_notice") | ||
def the_notice_transformation_is_executed(eligible_for_transformation_eForm_notice, mapping_suite, rml_mapper): | ||
"""the notice transformation is executed.""" | ||
transformed_notice = transform_notice(notice=eligible_for_transformation_eForm_notice, mapping_suite=mapping_suite, | ||
rml_mapper=rml_mapper) | ||
return transformed_notice | ||
|
||
|
||
@then('the notice has RDF manifestation') | ||
def the_notice_have_rdf_manifestation(transformed_notice: Notice): | ||
"""the notice have RDF manifestation.""" | ||
assert transformed_notice.rdf_manifestation | ||
assert transformed_notice.rdf_manifestation.object_data | ||
|
||
|
||
@then('the notice status is TRANSFORMED') | ||
def the_notice_status_is_transformed(transformed_notice: Notice): | ||
"""the notice status is TRANSFORMED.""" | ||
assert transformed_notice.status == NoticeStatus.TRANSFORMED |