How to use the fints.parser.FinTS3Parser function in fints

To help you get started, we’ve selected a few fints examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github raphaelm / python-fints / tests / test_formals.py View on Github external
def test_find_by_class():
    from conftest import TEST_MESSAGES
    from fints.parser import FinTS3Parser
    from fints.segments.message import HNHBS1

    m = FinTS3Parser().parse_message(TEST_MESSAGES['basic_complicated'])

    assert list(m.find_segments(HNHBS1))[0].__class__ == HNHBS1

    assert m.find_segment_first(HNHBS1).header.type == 'HNHBS'
github raphaelm / python-fints / tests / test_formals.py View on Github external
def test_find_1():
    from conftest import TEST_MESSAGES
    from fints.parser import FinTS3Parser
    from fints.segments.message import HNHBS1, HNHBK3

    m = FinTS3Parser().parse_message(TEST_MESSAGES['basic_complicated'])

    assert len(list(m.find_segments('HNHBK'))) == 1
    assert len(list(m.find_segments(['HNHBK', 'HNHBS']))) == 2

    assert len(list(m.find_segments(['HNHBK', 'HNHBS'], 1))) == 1
    assert len(list(m.find_segments(['HNHBK', 'HNHBS'], (1, 3)))) == 2

    assert isinstance(m.find_segment_first('HNHBK'), HNHBK3)
    assert isinstance(m.find_segment_first('HNHBS'), HNHBS1)

    assert m.find_segment_first('ITST') is None

    assert len(m.find_segment_first('HITANS', 1).parameter.twostep_parameters) == 2
    assert len(m.find_segment_first('HITANS', 3).parameter.twostep_parameters) == 6

    assert m.find_segment_first('HITANS', recurse=False) is None
github raphaelm / python-fints / tests / test_message_parser.py View on Github external
def test_robust_mode(mocker):
    mocker.patch('fints.parser.robust_mode', True)

    message1 = rb"""HNHBS:5:1'"""
    with pytest.warns(FinTSParserWarning, match='^Ignoring parser error.*: Required field'):
        m = FinTS3Parser().parse_message(message1)
        assert m.segments[0].__class__ == FinTS3Segment
github raphaelm / python-fints / tests / test_message_parser.py View on Github external
def test_parse_HIRMG2():
    d = b"HIRMG:3:2+0010::Nachricht entgegengenommen.+0100::Dialog beendet.'"
    m = FinTS3Parser().parse_message(d)

    seg = m.segments[0]
    assert seg.header.type == 'HIRMG'
    assert seg.responses[0].code == '0010'
    assert seg.responses[1].code == '0100'
    assert len(seg.responses) == 2
github raphaelm / python-fints / tests / test_message_serializer.py View on Github external
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']
github raphaelm / python-fints / tests / test_message_parser.py View on Github external
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)
github raphaelm / python-fints / tests / test_message_parser.py View on Github external
def test_parse_other(input_name):
    m = FinTS3Parser().parse_message(TEST_MESSAGES[input_name])
    assert isinstance(m, SegmentSequence)
    m.print_nested()
github raphaelm / python-fints / fints / types.py View on Github external
def __init__(self, segments=None):
        if isinstance(segments, bytes):
            from .parser import FinTS3Parser
            parser = FinTS3Parser()
            data = parser.explode_segments(segments)
            segments = [parser.parse_segment(segment) for segment in data]
        self.segments = list(segments) if segments else []