Esempio n. 1
0
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."""

    description = factories.AdditionalCodeDescriptionFactory.create(
        described_additionalcode__valid_between=date_ranges.no_end,
        validity_start=date_ranges.later.lower,
    )

    with pytest.raises(BusinessRuleViolation):
        business_rules.ACN5(description.transaction).validate(
            description.described_additionalcode, )
Esempio n. 2
0
def test_ACN5_start_dates_cannot_match():
    """No two associated description periods may have the same start date."""

    existing = factories.AdditionalCodeDescriptionFactory.create()
    duplicate = factories.AdditionalCodeDescriptionFactory.create(
        described_additionalcode=existing.described_additionalcode,
        validity_start=existing.validity_start,
    )

    with pytest.raises(BusinessRuleViolation):
        business_rules.ACN5(duplicate.transaction).validate(
            existing.described_additionalcode, )
Esempio n. 3
0
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."""

    description = factories.AdditionalCodeDescriptionFactory.create(
        described_additionalcode__valid_between=date_ranges.normal,
        validity_start=date_ranges.later.lower,
    )
    next_description = factories.AdditionalCodeDescriptionFactory.create(
        described_additionalcode=description.described_additionalcode,
        validity_start=date_ranges.starts_with_normal.lower,
    )

    with pytest.raises(BusinessRuleViolation):
        business_rules.ACN5(next_description.transaction).validate(
            description.described_additionalcode, )
Esempio n. 4
0
def test_ACN5_one_description_mandatory():
    """At least one description is mandatory."""
    additional_code = factories.AdditionalCodeFactory.create()
    with pytest.raises(BusinessRuleViolation):
        business_rules.ACN5(
            additional_code.transaction).validate(additional_code)