def test_parse() -> None: sscc = Sscc.parse("376130321109103420") assert sscc == Sscc( value="376130321109103420", prefix=GS1Prefix(value="761", usage="GS1 Schweiz, Suisse, Svizzera"), extension_digit=3, payload="37613032110910342", check_digit=0, )
from biip.sscc import Sscc @pytest.mark.parametrize( "value, expected", [ ( "00373400306809981733", GS1ElementString( ai=GS1ApplicationIdentifier.extract("00"), value="373400306809981733", pattern_groups=["373400306809981733"], sscc=Sscc( value="373400306809981733", prefix=GS1Prefix(value="734", usage="GS1 Sweden"), extension_digit=3, payload="37340030680998173", check_digit=3, ), ), ), ( "0107032069804988", GS1ElementString( ai=GS1ApplicationIdentifier.extract("01"), value="07032069804988", pattern_groups=["07032069804988"], gtin=Gtin( value="07032069804988", format=GtinFormat.GTIN_13, prefix=GS1Prefix(value="703", usage="GS1 Norway"),
), ), ( # SSCC "376130321109103420", ParseResult( value="376130321109103420", gs1_message_error=( "Failed to get GS1 Application Identifier from '09103420'." ), gtin_error=("Failed to parse '376130321109103420' as GTIN: " "Expected 8, 12, 13, or 14 digits, got 18."), sscc=Sscc( value="376130321109103420", prefix=GS1Prefix(value="761", usage="GS1 Schweiz, Suisse, Svizzera"), extension_digit=3, payload="37613032110910342", check_digit=0, ), ), ), ( # GS1 AI: SSCC "00376130321109103420", ParseResult( value="00376130321109103420", gtin_error=("Failed to parse '00376130321109103420' as GTIN: " "Expected 8, 12, 13, or 14 digits, got 20."), gs1_message=GS1Message( value="00376130321109103420", element_strings=[