Test bank import

This commit is contained in:
Tobias Kunze 2018-01-11 20:53:41 +01:00
parent 020c6cf36d
commit 97c6d64068
2 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,27 @@
import pytest
from byro_shackspace.utils import process_bank_csv
from django.core.files.uploadedfile import InMemoryUploadedFile
from byro.bookkeeping.models import RealTransactionSource
@pytest.fixture
def bank_transaction_csv_file():
actual_file = open('tests/fixtures/transactions.csv', encoding='iso-8859-1')
f = InMemoryUploadedFile(
file=actual_file,
field_name=None,
name='transactions.csv',
content_type='text',
size=len(actual_file.read()),
charset='iso-8859-1',
)
return RealTransactionSource.objects.create(source_file=f)
@pytest.mark.django_db
def test_bank_import(bank_transaction_csv_file):
assert bank_transaction_csv_file.transactions.count() == 0
process_bank_csv(bank_transaction_csv_file)
bank_transaction_csv_file.refresh_from_db()
assert bank_transaction_csv_file.transactions.count() == 6

2
pytest.ini Normal file
View File

@ -0,0 +1,2 @@
[pytest]
DJANGO_SETTINGS_MODULE = byro.settings