Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'2:',
b'5@+\':',
],
],
[
['IIMPTST', '2', '1'],
'3?',
'4',
]
]
s = FinTS3Serializer.implode_segments(m)
assert s == rb"""IIMPTST:1:1+1?'+2?++1?@:2?::@5@5@+':'IIMPTST:2:1+3??+4'"""
assert FinTS3Parser.explode_segments(s) == m
def test_explode(input_name):
segments = FinTS3Parser.explode_segments(TEST_MESSAGES[input_name])
if input_name.startswith('basic_'):
assert len(segments) == 4
def test_invalid():
message1 = rb"""12"""
with pytest.raises(ValueError):
FinTS3Parser.explode_segments(message1)
message2 = rb"""@2@12ab'"""
with pytest.raises(ValueError):
FinTS3Parser.explode_segments(message2)
message3 = rb"""ab@2@12'"""
with pytest.raises(ValueError):
FinTS3Parser.explode_segments(message3)
message4 = rb"""ab@@'"""
with pytest.raises(ValueError):
FinTS3Parser.explode_segments(message4)
message5 = rb"""@2@12ab"""
with pytest.raises(ValueError):
FinTS3Parser.explode_segments(message5)
def test_invalid():
message1 = rb"""12"""
with pytest.raises(ValueError):
FinTS3Parser.explode_segments(message1)
message2 = rb"""@2@12ab'"""
with pytest.raises(ValueError):
FinTS3Parser.explode_segments(message2)
message3 = rb"""ab@2@12'"""
with pytest.raises(ValueError):
FinTS3Parser.explode_segments(message3)
message4 = rb"""ab@@'"""
with pytest.raises(ValueError):
FinTS3Parser.explode_segments(message4)
FinTS3Parser.explode_segments(message2)
message3 = rb"""ab@2@12'"""
with pytest.raises(ValueError):
FinTS3Parser.explode_segments(message3)
message4 = rb"""ab@@'"""
with pytest.raises(ValueError):
FinTS3Parser.explode_segments(message4)
message5 = rb"""@2@12ab"""
with pytest.raises(ValueError):
FinTS3Parser.explode_segments(message5)
message6 = rb"""HNHBS:5:1'"""
with pytest.raises(FinTSParserError, match='^Required field'):
m = FinTS3Parser().parse_message(message6)
def test_implode_roundtrip_simple():
segments = FinTS3Parser.explode_segments(TEST_MESSAGES['basic_simple'])
assert FinTS3Serializer.implode_segments(segments) == TEST_MESSAGES['basic_simple']
message = FinTS3Parser().parse_message(segments)
assert FinTS3Serializer().serialize_message(message) == TEST_MESSAGES['basic_simple']
def test_invalid():
message1 = rb"""12"""
with pytest.raises(ValueError):
FinTS3Parser.explode_segments(message1)
message2 = rb"""@2@12ab'"""
with pytest.raises(ValueError):
FinTS3Parser.explode_segments(message2)
message3 = rb"""ab@2@12'"""
with pytest.raises(ValueError):
FinTS3Parser.explode_segments(message3)
message4 = rb"""ab@@'"""
with pytest.raises(ValueError):
FinTS3Parser.explode_segments(message4)
message5 = rb"""@2@12ab"""
with pytest.raises(ValueError):
FinTS3Parser.explode_segments(message5)
message6 = rb"""HNHBS:5:1'"""
with pytest.raises(FinTSParserError, match='^Required field'):
m = FinTS3Parser().parse_message(message6)
FinTS3Parser.explode_segments(message1)
message2 = rb"""@2@12ab'"""
with pytest.raises(ValueError):
FinTS3Parser.explode_segments(message2)
message3 = rb"""ab@2@12'"""
with pytest.raises(ValueError):
FinTS3Parser.explode_segments(message3)
message4 = rb"""ab@@'"""
with pytest.raises(ValueError):
FinTS3Parser.explode_segments(message4)
message5 = rb"""@2@12ab"""
with pytest.raises(ValueError):
FinTS3Parser.explode_segments(message5)
message6 = rb"""HNHBS:5:1'"""
with pytest.raises(FinTSParserError, match='^Required field'):
m = FinTS3Parser().parse_message(message6)