|
| 1 | +"""Notice metadata processor 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 Notice, NoticeStatus |
| 11 | +from ted_sws.data_manager.adapters.repository_abc import MappingSuiteRepositoryABC |
| 12 | +from ted_sws.notice_metadata_processor.services.notice_eligibility import notice_eligibility_checker |
| 13 | + |
| 14 | + |
| 15 | +@scenario('test_notice_eligibility.feature', 'Notice eligibility checking negative') |
| 16 | +def test_notice_eligibility_checking_negative(): |
| 17 | + """Notice eligibility checking negative.""" |
| 18 | + |
| 19 | + |
| 20 | +@scenario('test_notice_eligibility.feature', 'Notice eligibility checking positive') |
| 21 | +def test_notice_eligibility_checking_positive(): |
| 22 | + """Notice eligibility checking positive.""" |
| 23 | + |
| 24 | + |
| 25 | +@given('a mapping suite for F03 is available in mapping suite repository', target_fixture="mapping_suite_repository") |
| 26 | +def a_mapping_suite_for_f03_is_available_in_mapping_suite_repository(clean_mapping_suite_repository, |
| 27 | + mapping_suite_repository_with_mapping_suite): |
| 28 | + """a mapping suite for F03 is available in mapping suite repository.""" |
| 29 | + for mapping_suite in mapping_suite_repository_with_mapping_suite.list(): |
| 30 | + clean_mapping_suite_repository.add(mapping_suite=mapping_suite) |
| 31 | + return clean_mapping_suite_repository |
| 32 | + |
| 33 | + |
| 34 | +@given('a mapping suite for F03 is not available in mapping suite repository', |
| 35 | + target_fixture="mapping_suite_repository") |
| 36 | +def a_mapping_suite_for_f03_is_not_available_in_mapping_suite_repository(clean_mapping_suite_repository): |
| 37 | + """a mapping suite for F03 is not available in mapping suite repository.""" |
| 38 | + return clean_mapping_suite_repository |
| 39 | + |
| 40 | + |
| 41 | +@given('a mapping suite repository') |
| 42 | +def a_mapping_suite_repository(clean_mapping_suite_repository): |
| 43 | + """a mapping suite repository.""" |
| 44 | + assert clean_mapping_suite_repository |
| 45 | + assert isinstance(clean_mapping_suite_repository, MappingSuiteRepositoryABC) |
| 46 | + |
| 47 | + |
| 48 | +@given('a notice') |
| 49 | +def a_notice(normalised_notice): |
| 50 | + """a notice.""" |
| 51 | + assert normalised_notice |
| 52 | + assert isinstance(normalised_notice, Notice) |
| 53 | + |
| 54 | + |
| 55 | +@given('the notice is with form number F03') |
| 56 | +def the_notice_is_with_form_number_f03(normalised_notice): |
| 57 | + """the notice is with form number F03.""" |
| 58 | + assert normalised_notice.normalised_metadata.form_number == "F03" |
| 59 | + |
| 60 | + |
| 61 | +@given('the notice status is NORMALISED') |
| 62 | +def the_notice_status_is_normalised(normalised_notice): |
| 63 | + """the notice status is NORMALISED.""" |
| 64 | + assert normalised_notice.status == NoticeStatus.NORMALISED_METADATA |
| 65 | + |
| 66 | + |
| 67 | +@when('the notice eligibility checking is executed', target_fixture="checked_notice") |
| 68 | +def the_notice_eligibility_checking_is_executed(normalised_notice, mapping_suite_repository): |
| 69 | + """the notice eligibility checking is executed.""" |
| 70 | + notice_eligibility_checker(notice=normalised_notice, mapping_suite_repository=mapping_suite_repository) |
| 71 | + return normalised_notice |
| 72 | + |
| 73 | + |
| 74 | +@then('the notice status is ELIGIBLE_FOR_TRANSFORMATION') |
| 75 | +def the_notice_status_is_eligible_for_transformation(checked_notice: Notice): |
| 76 | + """the notice status is ELIGIBLE_FOR_TRANSFORMATION.""" |
| 77 | + assert checked_notice.status == NoticeStatus.ELIGIBLE_FOR_TRANSFORMATION |
| 78 | + |
| 79 | + |
| 80 | +@then('the notice status is INELIGIBLE_FOR_TRANSFORMATION') |
| 81 | +def the_notice_status_is_ineligible_for_transformation(checked_notice: Notice): |
| 82 | + """the notice status is INELIGIBLE_FOR_TRANSFORMATION.""" |
| 83 | + assert checked_notice.status == NoticeStatus.INELIGIBLE_FOR_TRANSFORMATION |
0 commit comments