def test_NIG11_no_overlapping_indents(): """No two associated indentations may have the same start date.""" existing = factories.GoodsNomenclatureIndentFactory.create() duplicate = factories.GoodsNomenclatureIndentFactory.create( indented_goods_nomenclature=existing.indented_goods_nomenclature, valid_between=existing.valid_between, ) with pytest.raises(BusinessRuleViolation): business_rules.NIG11(duplicate.transaction).validate( existing.indented_goods_nomenclature, )
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.""" indent = factories.GoodsNomenclatureIndentFactory.create( indented_goods_nomenclature__valid_between=date_ranges.normal, valid_between=date_ranges.later, ) with pytest.raises(BusinessRuleViolation): business_rules.NIG11(indent.transaction).validate( indent.indented_goods_nomenclature, )
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.""" indent = factories.GoodsNomenclatureIndentFactory.create( indented_goods_nomenclature__valid_between=date_ranges.normal, valid_between=date_ranges.overlap_normal, ) with pytest.raises(BusinessRuleViolation): business_rules.NIG11(indent.transaction).validate( indent.indented_goods_nomenclature, )
def test_NIG11_one_indent_mandatory(): """At least one indent record is mandatory.""" good = factories.GoodsNomenclatureFactory.create(indent=None) with pytest.raises(BusinessRuleViolation): business_rules.NIG11(good.transaction).validate(good)