Test bank import
This commit is contained in:
parent
020c6cf36d
commit
97c6d64068
27
byro_shackspace/tests/test_bank_import.py
Normal file
27
byro_shackspace/tests/test_bank_import.py
Normal 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
2
pytest.ini
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[pytest]
|
||||||
|
DJANGO_SETTINGS_MODULE = byro.settings
|
Loading…
Reference in New Issue
Block a user