示例#1
0
def test_identify_invalid_iban(tmp_file):
    other_iban = '5678********1234'

    tmp_file.write(
        _format(
            '''
            "Kreditkarte:";"{card_number} Kreditkarte";

            "Von:";"01.01.2018";
            "Bis:";"31.01.2018";
            "Saldo:";"5000.01 EUR";
            "Datum:";"30.01.2018";

            {header};
            ''',
            dict(
                card_number=Constants.card_number.value,
                header=Constants.header.value,
            ),
        )
    )

    importer = CreditImporter(other_iban, 'Assets:DKB:Credit')

    with open(str(tmp_file.realpath())) as fd:
        assert not importer.identify(fd)
示例#2
0
def test_multiple_headers(tmp_file):
    importer = CreditImporter(Constants.card_number.value, 'Assets:DKB:Credit')

    common = '''
        "Von:";"01.01.2018";
        "Bis:";"31.01.2018";
        "Saldo:";"5000.01 EUR";
        "Datum:";"30.01.2018";
    '''

    # previous header format
    tmp_file.write(
        _format(
            '''
            "Kreditkarte:";"{card_number} Kreditkarte";

            {common}

            ''',
            dict(card_number=Constants.card_number.value, common=common),
        )
    )

    with open(str(tmp_file.realpath())) as fd:
        assert importer.identify(fd)

    # latest header format
    tmp_file.write(
        _format(
            '''
            "Kreditkarte:";"{card_number}";

            {common}

            ''',
            dict(card_number=Constants.card_number.value, common=common),
        )
    )

    with open(str(tmp_file.realpath())) as fd:
        assert importer.identify(fd)
    def test_multiple_headers(self):
        importer = CreditImporter(self.card_number, 'Assets:DKB:Credit')

        common = '''
            "Von:";"01.01.2018";
            "Bis:";"31.01.2018";
            "Saldo:";"5000.01 EUR";
            "Datum:";"30.01.2018";
        '''

        # previous header format
        with open(self.filename, 'wb') as fd:
            fd.write(
                _format(
                    '''
                    "Kreditkarte:";"{card_number} Kreditkarte";

                    {common}

                    ''',
                    dict(card_number=self.card_number, common=common),
                ))

        with open(self.filename) as fd:
            self.assertTrue(importer.identify(fd))

        # latest header format
        with open(self.filename, 'wb') as fd:
            fd.write(
                _format(
                    '''
                    "Kreditkarte:";"{card_number}";

                    {common}

                    ''',
                    dict(card_number=self.card_number, common=common),
                ))

        with open(self.filename) as fd:
            self.assertTrue(importer.identify(fd))
示例#4
0
def test_multiple_headers(tmp_file):
    importer = CreditImporter(CARD_NUMBER, 'Assets:DKB:Credit')

    common = '''
        "Von:";"01.01.2018";
        "Bis:";"31.01.2018";
        "Saldo:";"5000.01 EUR";
        "Datum:";"30.01.2018";
    '''

    # previous header format
    tmp_file.write_text(
        _format(
            '''
            "Kreditkarte:";"{card_number} Kreditkarte";

            {common}

            ''',
            dict(card_number=CARD_NUMBER, common=common),
        ))

    with tmp_file.open() as fd:
        assert importer.identify(fd)

    # latest header format
    tmp_file.write_text(
        _format(
            '''
            "Kreditkarte:";"{card_number}";

            {common}

            ''',
            dict(card_number=CARD_NUMBER, common=common),
        ))

    with tmp_file.open() as fd:
        assert importer.identify(fd)
示例#5
0
    def test_identify_correct(self):
        importer = CreditImporter(self.card_number, 'Assets:DKB:Credit')

        with open(self.filename, 'wb') as fd:
            fd.write(
                _format(
                    '''
                "Kreditkarte:";"{card_number} Kreditkarte";

                "Von:";"01.01.2018";
                "Bis:";"31.01.2018";
                "Saldo:";"5.000,01 EUR";
                "Datum:";"15.02.2018";

                {header};
            ''', dict(card_number=self.card_number, header=HEADER)))

        with open(self.filename) as fd:
            self.assertTrue(importer.identify(fd))
示例#6
0
def test_identify_correct(tmp_file):
    importer = CreditImporter(CARD_NUMBER, 'Assets:DKB:Credit')

    tmp_file.write_text(
        _format(
            '''
            "Kreditkarte:";"{card_number} Kreditkarte";

            "Von:";"01.01.2018";
            "Bis:";"31.01.2018";
            "Saldo:";"5000.01 EUR";
            "Datum:";"30.01.2018";

            {header};
            ''',
            dict(card_number=CARD_NUMBER, header=HEADER),
        ))

    with tmp_file.open() as fd:
        assert importer.identify(fd)
示例#7
0
    def test_identify_invalid_iban(self):
        other_iban = '5678********1234'

        with open(self.filename, 'wb') as fd:
            fd.write(
                _format(
                    '''
                "Kreditkarte:";"{card_number} Kreditkarte";

                "Von:";"01.01.2018";
                "Bis:";"31.01.2018";
                "Saldo:";"5.000,01 EUR";
                "Datum:";"15.02.2018";

                {header};
            ''', dict(card_number=self.card_number, header=HEADER)))

        importer = CreditImporter(other_iban, 'Assets:DKB:Credit')

        with open(self.filename) as fd:
            self.assertFalse(importer.identify(fd))
示例#8
0
def test_identify_invalid_iban(tmp_file):
    other_iban = '5678********1234'

    tmp_file.write_text(
        _format(
            '''
            "Kreditkarte:";"{card_number} Kreditkarte";

            "Von:";"01.01.2018";
            "Bis:";"31.01.2018";
            "Saldo:";"5000.01 EUR";
            "Datum:";"30.01.2018";

            {header};
            ''',
            dict(card_number=CARD_NUMBER, header=HEADER),
        ))

    importer = CreditImporter(other_iban, 'Assets:DKB:Credit')

    with tmp_file.open() as fd:
        assert not importer.identify(fd)
示例#9
0
def test_identify_correct(tmp_file):
    importer = CreditImporter(Constants.card_number.value, 'Assets:DKB:Credit')

    tmp_file.write(
        _format(
            '''
            "Kreditkarte:";"{card_number} Kreditkarte";

            "Von:";"01.01.2018";
            "Bis:";"31.01.2018";
            "Saldo:";"5000.01 EUR";
            "Datum:";"30.01.2018";

            {header};
            ''',
            dict(
                card_number=Constants.card_number.value,
                header=Constants.header.value,
            ),
        )
    )

    with open(str(tmp_file.realpath())) as fd:
        assert importer.identify(fd)