Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to QA5 to prevent False positives from deleted associations #1371

Merged
merged 4 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions additional_codes/tests/test_business_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# Additional Code Type


@pytest.mark.business_rules
@pytest.mark.xfail(reason="CT1 disabled")
def test_CT1(assert_handles_duplicates):
"""The additional code type must be unique."""
Expand All @@ -26,6 +27,7 @@ def test_CT1(assert_handles_duplicates):
)


@pytest.mark.business_rules
@requires_meursing_tables
def test_CT2():
"""The Meursing table plan can only be entered if the additional code type
Expand All @@ -34,13 +36,15 @@ def test_CT2():
assert False


@pytest.mark.business_rules
@requires_meursing_tables
def test_CT3():
"""The Meursing table plan must exist."""

assert False


@pytest.mark.business_rules
def test_CT4(date_ranges):
"""The start date must be less than or equal to the end date."""
with pytest.raises(DataError):
Expand All @@ -50,6 +54,7 @@ def test_CT4(date_ranges):
# Additional Code


@pytest.mark.business_rules
def test_ACN1(assert_handles_duplicates):
"""The combination of additional code type + additional code + start date
must be unique."""
Expand All @@ -61,6 +66,7 @@ def test_ACN1(assert_handles_duplicates):
)


@pytest.mark.business_rules
def test_ACN2_type_must_exist(reference_nonexistent_record):
"""The referenced additional code type must exist."""

Expand All @@ -72,6 +78,7 @@ def test_ACN2_type_must_exist(reference_nonexistent_record):
assert ac.type is None


@pytest.mark.business_rules
@pytest.mark.parametrize(
"app_code, expect_error",
[
Expand All @@ -92,6 +99,7 @@ def test_ACN2_allowed_application_codes(app_code, expect_error):
business_rules.ACN2(additional_code.transaction).validate(additional_code)


@pytest.mark.business_rules
def test_ACN3(date_ranges):
"""The start date of the additional code must be less than or equal to the
end date."""
Expand All @@ -100,6 +108,7 @@ def test_ACN3(date_ranges):
factories.AdditionalCodeFactory.create(valid_between=date_ranges.backwards)


@pytest.mark.business_rules
def test_ACN4(date_ranges):
"""The validity period of the additional code must not overlap any other
additional code with the same additional code type + additional code + start
Expand All @@ -119,6 +128,7 @@ def test_ACN4(date_ranges):
business_rules.ACN4(duplicate.transaction).validate(duplicate)


@pytest.mark.business_rules
@requires_meursing_tables
def text_ACN12():
"""When the additional code is used to represent an additional code line
Expand All @@ -128,6 +138,7 @@ def text_ACN12():
assert False


@pytest.mark.business_rules
def test_ACN13(assert_spanning_enforced):
"""When an additional code is used in an additional code nomenclature
measure then the validity period of the additional code must span the
Expand All @@ -144,6 +155,7 @@ def test_ACN13(assert_spanning_enforced):
)


@pytest.mark.business_rules
def test_ACN17(assert_spanning_enforced):
"""The validity period of the additional code type must span the validity
period of the additional code."""
Expand All @@ -160,13 +172,15 @@ def test_ACN17(assert_spanning_enforced):
footnote_association = pytest.mark.skip(reason="Footnote association is not required.")


@pytest.mark.business_rules
@footnote_association
def test_ACN6():
"""The footnotes that are referenced must exist."""

assert False


@pytest.mark.business_rules
@footnote_association
def test_ACN7():
"""The start date of the footnote association must be less than or equal to
Expand All @@ -175,6 +189,7 @@ def test_ACN7():
assert False


@pytest.mark.business_rules
@footnote_association
def test_ACN8():
"""The period of the association with a footnote must be within (inclusive)
Expand All @@ -183,6 +198,7 @@ def test_ACN8():
assert False


@pytest.mark.business_rules
@footnote_association
def test_ACN9():
"""The period of the association with a footnote must be within (inclusive)
Expand All @@ -191,6 +207,7 @@ def test_ACN9():
assert False


@pytest.mark.business_rules
@footnote_association
def test_ACN10():
"""When the same footnote is associated more than once with the same
Expand All @@ -200,6 +217,7 @@ def test_ACN10():
assert False


@pytest.mark.business_rules
@footnote_association
def test_ACN11():
"""The referenced footnote must have a footnote type with application type =
Expand All @@ -211,6 +229,7 @@ def test_ACN11():
# Additional Code Description and Description Periods


@pytest.mark.business_rules
def test_ACN5_one_description_mandatory():
"""At least one description is mandatory."""
additional_code = factories.AdditionalCodeFactory.create()
Expand All @@ -219,6 +238,7 @@ def test_ACN5_one_description_mandatory():
business_rules.ACN5(additional_code.transaction).validate(additional_code)


@pytest.mark.business_rules
def test_ACN5_first_description_must_have_same_start_date(date_ranges):
"""The start date of the first description period must be equal to the start
date of the additional code."""
Expand All @@ -234,6 +254,7 @@ def test_ACN5_first_description_must_have_same_start_date(date_ranges):
)


@pytest.mark.business_rules
def test_ACN5_start_dates_cannot_match():
"""No two associated description periods may have the same start date."""

Expand All @@ -249,6 +270,7 @@ def test_ACN5_start_dates_cannot_match():
)


@pytest.mark.business_rules
def test_ACN5_description_start_before_additional_code_end(date_ranges):
"""The start date must be less than or equal to the end date of the
additional code."""
Expand All @@ -268,6 +290,7 @@ def test_ACN5_description_start_before_additional_code_end(date_ranges):
)


@pytest.mark.business_rules
def test_ACN14(delete_record):
"""An additional code cannot be deleted if it is used in an additional code
nomenclature measure."""
Expand All @@ -288,6 +311,7 @@ def test_ACN14(delete_record):
)


@pytest.mark.business_rules
@requires_meursing_tables
def test_ACN15():
"""An additional code cannot be deleted if it is used in an additional code
Expand Down
12 changes: 12 additions & 0 deletions certificates/tests/test_business_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
pytestmark = pytest.mark.django_db


@pytest.mark.business_rules
def test_CET1(assert_handles_duplicates):
"""The type of the Certificate must be unique."""

Expand All @@ -18,6 +19,7 @@ def test_CET1(assert_handles_duplicates):
)


@pytest.mark.business_rules
def test_CET2(delete_record):
"""The Certificate type cannot be deleted if it is used in a Certificate."""

Expand All @@ -29,13 +31,15 @@ def test_CET2(delete_record):
)


@pytest.mark.business_rules
def test_CET3(date_ranges):
"""The start date must be less than or equal to the end date."""

with pytest.raises(DataError):
factories.CertificateTypeFactory.create(valid_between=date_ranges.backwards)


@pytest.mark.business_rules
@pytest.mark.xfail(reason="CE2 disabled")
def test_CE2(assert_handles_duplicates):
"""The combination of certificate type and code must be unique."""
Expand All @@ -47,13 +51,15 @@ def test_CE2(assert_handles_duplicates):
)


@pytest.mark.business_rules
def test_CE3(date_ranges):
"""The start date must be less than or equal to the end date."""

with pytest.raises(DataError):
factories.CertificateFactory.create(valid_between=date_ranges.backwards)


@pytest.mark.business_rules
def test_CE4(assert_spanning_enforced):
"""If a certificate is used in a measure condition then the validity period
of the certificate must span the validity period of the measure."""
Expand All @@ -68,6 +74,7 @@ def test_CE4(assert_spanning_enforced):
)


@pytest.mark.business_rules
def test_CE5(delete_record):
"""The certificate cannot be deleted if it is used in a measure
condition."""
Expand All @@ -80,6 +87,7 @@ def test_CE5(delete_record):
)


@pytest.mark.business_rules
def test_CE6_one_description_mandatory():
"""At least one description record is mandatory."""
certificate = factories.CertificateFactory.create(description=None)
Expand All @@ -89,6 +97,7 @@ def test_CE6_one_description_mandatory():
business_rules.CE6(certificate.transaction).validate(certificate)


@pytest.mark.business_rules
def test_CE6_first_description_must_have_same_start_date(date_ranges):
"""The start date of the first description period must be equal to the start
date of the certificate."""
Expand All @@ -104,6 +113,7 @@ def test_CE6_first_description_must_have_same_start_date(date_ranges):
)


@pytest.mark.business_rules
def test_CE6_start_dates_cannot_match():
"""No two associated description periods for the same certificate and
language may have the same start date."""
Expand All @@ -120,6 +130,7 @@ def test_CE6_start_dates_cannot_match():
)


@pytest.mark.business_rules
def test_CE6_certificate_validity_period_must_span_description(date_ranges):
"""The validity period of the certificate must span the validity period of
the certificate description."""
Expand All @@ -135,6 +146,7 @@ def test_CE6_certificate_validity_period_must_span_description(date_ranges):
)


@pytest.mark.business_rules
def test_CE7(assert_spanning_enforced):
"""The validity period of the certificate type must span the validity period
of the certificate."""
Expand Down
5 changes: 5 additions & 0 deletions commodities/tests/business_rules/test_NIG11.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
pytestmark = pytest.mark.django_db


@pytest.mark.business_rules
def test_NIG11_one_indent_mandatory():
"""At least one indent record is mandatory."""

Expand All @@ -16,6 +17,7 @@ def test_NIG11_one_indent_mandatory():
business_rules.NIG11(good.transaction).validate(good)


@pytest.mark.business_rules
def test_NIG11_first_indent_must_have_same_start_date(date_ranges):
"""The start date of the first indentation must be equal to the start date
of the nomenclature."""
Expand All @@ -31,6 +33,7 @@ def test_NIG11_first_indent_must_have_same_start_date(date_ranges):
)


@pytest.mark.business_rules
def test_NIG11_no_overlapping_indents():
"""No two associated indentations may have the same start date."""

Expand All @@ -45,6 +48,7 @@ def test_NIG11_no_overlapping_indents():
)


@pytest.mark.business_rules
def test_NIG11_start_date_less_than_end_date(date_ranges):
"""The start date must be less than or equal to the end date of the
nomenclature."""
Expand All @@ -60,6 +64,7 @@ def test_NIG11_start_date_less_than_end_date(date_ranges):
)


@pytest.mark.business_rules
def test_NIG11_skips_when_goods_deleted(date_ranges):
"""Example failure,"""

Expand Down
2 changes: 2 additions & 0 deletions commodities/tests/business_rules/test_NIG5.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
pytestmark = pytest.mark.django_db


@pytest.mark.business_rules
def test_NIG5(workbasket):
"""
When creating a goods nomenclature code, an origin must exist.
Expand Down Expand Up @@ -36,6 +37,7 @@ def test_NIG5(workbasket):
business_rules.NIG5(good_good.transaction).validate(good_good)


@pytest.mark.business_rules
def test_NIG5_allow_origin_create():
"""
When creating a goods nomenclature code, an origin must exist.
Expand Down
3 changes: 3 additions & 0 deletions commodities/tests/business_rules/test_NIG5_origin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
pytestmark = pytest.mark.django_db


@pytest.mark.business_rules
def test_NIG5_origin_raises_violation_when_only_origin_is_deleted(workbasket):
"""
When deleting an origin there must still be an origin for the goods,
Expand Down Expand Up @@ -68,6 +69,7 @@ def test_NIG5_origin_raises_violation_when_only_origin_is_deleted(workbasket):
business_rules.NIG5_origin(editable_transaction).validate(origin_delete)


@pytest.mark.business_rules
def test_NIG5_origin_does_not_raise_violation_when_origin_still_exists(workbasket):
"""
When deleting an origin there must still be an origin for the goods,
Expand Down Expand Up @@ -140,6 +142,7 @@ def test_NIG5_origin_does_not_raise_violation_when_origin_still_exists(workbaske
business_rules.NIG5_origin(editable_transaction).validate(origin_delete)


@pytest.mark.business_rules
def test_NIG5_origin_does_not_raise_violation_when_both_origin_and_goods_nomenclature_are_deleted(
workbasket,
):
Expand Down
Loading
Loading