How to use fints - 10 common examples

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_container_nested_init():
    class A(Container):
        a = NumericField()

    class B(Container):
        b = DataElementGroupField(type=A)

    i1 = A(a='5')
    i2 = B(b=i1)

    assert isinstance(i2.b, A)
    assert i2.b.a == 5

    class C(Container):
        c = DataElementGroupField(type=B)

    with pytest.raises(TypeError):
        C(c=i1)

    i3 = B()
    assert i3.b.a is None
github raphaelm / python-fints / tests / test_models.py View on Github external
signature_algorithm=fints.formals.SignatureAlgorithm(
                                                                                                                                                   usage_signature='6',
                                                                                                                                                   signature_algorithm='10',
                                                                                                                                                   operation_mode='16'),
                                                                                                                                               key_name=fints.formals.KeyName(
                                                                                                                                                   bank_identifier=fints.formals.BankIdentifier(
                                                                                                                                                       country_identifier='280',
                                                                                                                                                       bank_code='15050500'),
                                                                                                                                                   user_id='hermes',
                                                                                                                                                   key_type='S',
                                                                                                                                                   key_number=0,
                                                                                                                                                   key_version=0),
                                                                                                                                               certificate=fints.formals.Certificate(
                                                                                                                                                   certificate_type=None,
                                                                                                                                                   certificate_content=None)),
                                                                                                                                           fints.segments.base.FinTS3Segment(
                                                                                                                                               header=fints.formals.SegmentHeader(
                                                                                                                                                   'HIRMG', 3,
                                                                                                                                                   2, None),
                                                                                                                                               _additional_data=[
                                                                                                                                                   ['0010',
                                                                                                                                                    None,
                                                                                                                                                    'Nachricht entgegengenommen.'],
                                                                                                                                                   ['0100',
                                                                                                                                                    None,
                                                                                                                                                    'Dialog beendet.']]),
                                                                                                                                           fints.segments.base.FinTS3Segment(
                                                                                                                                               header=fints.formals.SegmentHeader(
                                                                                                                                                   'HNSHA', 4,
                                                                                                                                                   2, None),
                                                                                                                                               _additional_data=[
                                                                                                                                                   '9166926'])])),
github raphaelm / python-fints / tests / test_formals.py View on Github external
def test_container_count_exact():
    class A(Container):
        a = NumericField(count=2)

    i1 = A()

    assert len(i1.a) == 2

    assert i1.a[0] is None
    assert i1.a[1] is None

    with pytest.raises(IndexError):
        i1.a[2]

    with pytest.raises(IndexError):
        i1.a[2] = 1

    with pytest.raises(IndexError):
        i1.a[-1]
github raphaelm / python-fints / tests / test_formals.py View on Github external
def test_unset():
    class A(Container):
        a = NumericField()

    class B(Container):
        b = ContainerField(type=A)
        c = NumericField()

    assert A().is_unset()
    assert not A(a=1).is_unset()
    assert A(a=None).is_unset()

    assert B().is_unset()
    assert B(b=A()).is_unset()
    assert not B(c=1).is_unset()
github raphaelm / python-fints / tests / test_formals.py View on Github external
def test_container_nested():
    class A(Container):
        a = NumericField()

    class B(Container):
        b = DataElementGroupField(type=A)

    i1 = B()
    assert isinstance(i1.b, A)

    i1.b.a = '1'
    assert i1.b.a == 1
github raphaelm / python-fints / tests / test_formals.py View on Github external
def test_container_naive_parse():
    class A(Container):
        a = NumericField()
        b = DigitsField()

    i1 = A.naive_parse(['23', '42'])

    assert i1.a == 23
    assert i1.b == '42'
github raphaelm / python-fints / tests / test_models.py View on Github external
def test_fints3_only_de_and_deg():
    from fints.formals import Field, Container, DataElementGroupField

    with pytest.raises(TypeError, match="b=.* is not DataElementField or DataElementGroupField"):
        class Foo(FinTS3Segment):
            a = NumericField()
            b = Field()

    class A(Container):
        a = Field()

    class B(Container):
        b = DataElementGroupField(type=A)

    with pytest.raises(TypeError, match="a=.* is not DataElementField or DataElementGroupField"):
        class Foo(FinTS3Segment):
            c = DataElementGroupField(type=B)
github raphaelm / python-fints / tests / test_message_parser.py View on Github external
def test_parse_counted():
    from fints.segments.base import FinTS3Segment
    from fints.formals import NumericField, Container, ContainerField

    class ITST1(FinTS3Segment):
        a = NumericField(count=3)

    m1 = FinTS3Parser().parse_message(b"ITST:1:1+1+2+3'")
    assert m1.segments[0].header.type == 'ITST'
    assert len(m1.segments[0].a) == 3
    assert m1.segments[0].a[0] == 1
    assert m1.segments[0].a[1] == 2
    assert m1.segments[0].a[2] == 3

    class ITST2(FinTS3Segment):
        a = NumericField(max_count=3)

    m2 = FinTS3Parser().parse_message(b"ITST:1:2+1+2+3'")
    assert m2.segments[0].a[2] == 3

    m3 = FinTS3Parser().parse_message(b"ITST:1:2+1+2+3+4'")
    assert m3.segments[0]._additional_data == ['4']
github raphaelm / python-fints / tests / test_models.py View on Github external
def test_segment_subclassing():
    class Base1(FinTS3Segment):
        a = NumericField()

    class Base2(Base1):
        b = NumericField()

    class ISUBTST1(Base2):
        c = NumericField()

    assert list(ISUBTST1._fields.keys()) == ['header', 'a', 'b', 'c']
github raphaelm / python-fints / tests / test_formals.py View on Github external
def test_container_count_variable_1():
    class A(Container):
        a = NumericField(min_count=2, max_count=5)

    i1 = A()

    assert len(i1.a) == 2

    assert i1.a[0] is None
    assert i1.a[1] is None
    assert i1.a[3] is None

    assert len(i1.a) == 2

    with pytest.raises(IndexError):
        i1.a[5]

    with pytest.raises(IndexError):
        i1.a[5] = 1