示例#1
0
def test_NIG12_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 nomenclature."""
    good = factories.GoodsNomenclatureFactory.create(
        description__valid_between=date_ranges.later,
    )
    with pytest.raises(BusinessRuleViolation):
        business_rules.NIG12(good.transaction).validate(good)
示例#2
0
def test_NIG12_start_dates_cannot_match():
    """No two associated description periods may have the same start date."""

    goods_nomenclature = factories.GoodsNomenclatureFactory.create()
    duplicate = factories.GoodsNomenclatureDescriptionFactory.create(
        described_goods_nomenclature=goods_nomenclature,
        valid_between=goods_nomenclature.valid_between,
    )
    with pytest.raises(BusinessRuleViolation):
        business_rules.NIG12(duplicate.transaction).validate(goods_nomenclature)
示例#3
0
def test_NIG12_description_start_before_nomenclature_end(
    date_ranges,
    unapproved_transaction,
):
    """The start date must be less than or equal to the end date of the
    nomenclature."""

    goods_nomenclature = factories.GoodsNomenclatureFactory.create(
        valid_between=date_ranges.normal,
        description__valid_between=date_ranges.starts_with_normal,
        transaction=unapproved_transaction,
    )
    early_description = factories.GoodsNomenclatureDescriptionFactory.create(
        described_goods_nomenclature=goods_nomenclature,
        valid_between=date_ranges.later,
    )

    with pytest.raises(BusinessRuleViolation):
        business_rules.NIG12(early_description.transaction).validate(goods_nomenclature)
示例#4
0
def test_NIG12_one_description_mandatory():
    """At least one description record is mandatory."""
    good = factories.GoodsNomenclatureFactory.create(description=None)

    with pytest.raises(BusinessRuleViolation):
        business_rules.NIG12(good.transaction).validate(good)