コード例 #1
0
class TinkoffCSVParser(BaseCSVParser):
    columns = [
        Column(
            'requested_at',
            index=0,
            required=True,
            processor=DateTimeProcessor(['%d.%m.%Y %H:%M:%S']),
        ),
        Column('paid_at',
               index=1,
               required=False,
               processor=DateProcessor(['%d.%m.%Y'])),
        Column('card_last_digits', index=2, required=True),
        Column('status', index=3, required=True),
        Column('amount_currency',
               index=4,
               required=True,
               processor=DecimalProcessor()),
        Column('currency', index=5, required=True),
        Column('amount_rub',
               index=6,
               required=True,
               processor=DecimalProcessor()),
        Column('category', index=9, required=True),
        Column('mcc_code',
               index=10,
               required=False,
               processor=IntegerProcessor()),
        Column('description', index=11, required=True),
    ]
コード例 #2
0
def test_integer_processor_exception(value, expected_error_message):
    processor = IntegerProcessor()

    with pytest.raises(ColumnError) as exc_info:
        processor(value)
    assert exc_info.value.messages == [expected_error_message]
コード例 #3
0
def test_integer_processor(value, expected_value):
    processor = IntegerProcessor()

    assert processor(value) == expected_value
コード例 #4
0
        ('2', {
            '1': 'First',
            '2': 'Second'
        }, None, 'Second'),
        (2, {
            '1': 'First',
            '2': 'Second'
        }, None, 'Second'),
        (' 2 ', {
            '1': 'First',
            '2': 'Second'
        }, None, 'Second'),
        (' 2 ', {
            1: 'First',
            2: 'Second'
        }, IntegerProcessor(), 'Second'),
        (
            ' 31.12.2020 ',
            {
                datetime.date(2020, 12, 31): 'New Year',
                datetime.date(2020, 11, 11): 'typical day',
            },
            DateProcessor(formats=['%d.%m.%Y']),
            'New Year',
        ),
        ('True', {
            True: 'ok',
            False: 'fail'
        }, BooleanProcessor(), 'ok'),
    ),
)