@@ -28,25 +28,6 @@ def test_raise_error_when_providing_invalid_ofx_file(db, bank_account, user):
2828 ofx_importer = OFXImporter (invalid_ofx_file , bank_account , user )
2929
3030
31- def test_cora_ofx_file_with_one_transaction (db , request , bank_account , user ):
32- ofx_file_path = request .path .parent / "data" / "cora-one-transaction.ofx"
33- with open (ofx_file_path , "r" ) as ofx_file :
34- ofx_importer = OFXImporter (ofx_file , bank_account , user )
35-
36- transactions = ofx_importer .run ()
37-
38- assert len (transactions ) == 1
39- transaction = transactions [0 ]
40- assert transaction .reference == "16b3dab5-d1ca-41e1-87c2-a26920ae70ac"
41- assert transaction .date == datetime .date (2024 , 8 , 19 )
42- assert transaction .description == "Debito em Conta"
43- assert transaction .amount == decimal .Decimal ("-2500.50" )
44- assert transaction .notes == ""
45- assert transaction .bank_account == bank_account
46- assert transaction .created_by == user
47- assert transaction .category is None
48-
49-
5031def test_bradesco_ofx_file_with_one_transaction (db , request , bank_account , user ):
5132 ofx_file_path = request .path .parent / "data" / "bradesco-one-transaction.ofx"
5233 with open (ofx_file_path , "r" ) as ofx_file :
@@ -66,29 +47,6 @@ def test_bradesco_ofx_file_with_one_transaction(db, request, bank_account, user)
6647 assert transaction .category is None
6748
6849
69- def test_ofx_file_with_multiple_transactions (db , request , bank_account , user ):
70- ofx_file_path = request .path .parent / "data" / "cora-multiple-transactions.ofx"
71- with open (ofx_file_path , "r" ) as ofx_file :
72- ofx_importer = OFXImporter (ofx_file , bank_account , user )
73-
74- transactions = ofx_importer .run ()
75-
76- references = sorted ([transaction .reference for transaction in transactions ])
77- expected_references = sorted (
78- [
79- "3825c888-1017-497d-bee2-c0737d5dafc0" ,
80- "63c41497-5e0b-4a3c-ada1-d9abebb0af39" ,
81- "69b66fe5-0360-466c-b2e5-08efc1768389" ,
82- "39221b44-f648-44ec-b6d1-1d8eefe54e02" ,
83- "6b01e19f-fc2f-4ea7-b524-6f6c634aea63" ,
84- ]
85- )
86-
87- assert len (transactions ) == 5
88- assert Transaction .objects .count () == 5
89- assert references == expected_references
90-
91-
9250def test_bradesco_ofx_file_with_multiple_transactions (db , request , bank_account , user ):
9351 ofx_file_path = request .path .parent / "data" / "bradesco-multiple-transactions.ofx"
9452 with open (ofx_file_path , "r" ) as ofx_file :
@@ -100,122 +58,6 @@ def test_bradesco_ofx_file_with_multiple_transactions(db, request, bank_account,
10058 assert Transaction .objects .count () == 57
10159
10260
103- def test_import_same_ofx_file_twice_will_not_duplicate_transactions (
104- db , request , bank_account , user
105- ):
106- ofx_file_path = request .path .parent / "data" / "cora-multiple-transactions.ofx"
107- with open (ofx_file_path , "r" ) as ofx_file :
108- ofx_importer = OFXImporter (ofx_file , bank_account , user )
109- transactions = ofx_importer .run ()
110- assert Transaction .objects .all ().count () == 5
111-
112- with open (ofx_file_path , "r" ) as ofx_file :
113- ofx_importer = OFXImporter (ofx_file , bank_account , user )
114- transactions = ofx_importer .run ()
115- assert Transaction .objects .all ().count () == 5
116-
117-
118- def test_import_ofx_file_that_overlaps_other_already_imported_do_not_duplicate_transactions (
119- db , request , bank_account , user
120- ):
121- ofx_file_path = request .path .parent / "data" / "cora-multiple-transactions.ofx"
122- with open (ofx_file_path , "r" ) as ofx_file :
123- ofx_importer = OFXImporter (ofx_file , bank_account , user )
124- _ = ofx_importer .run ()
125- assert Transaction .objects .all ().count () == 5
126-
127- ofx_file_path = (
128- request .path .parent / "data" / "cora-multiple-transactions-extended.ofx"
129- )
130- with open (ofx_file_path , "r" ) as ofx_file :
131- ofx_importer = OFXImporter (ofx_file , bank_account , user )
132- transactions = ofx_importer .run ()
133- assert Transaction .objects .all ().count () == 7
134-
135- references = sorted ([transaction .reference for transaction in transactions ])
136- expected_references = sorted (
137- [
138- "3825c888-1017-497d-bee2-c0737d5dafc0" ,
139- "63c41497-5e0b-4a3c-ada1-d9abebb0af39" ,
140- "69b66fe5-0360-466c-b2e5-08efc1768389" ,
141- "39221b44-f648-44ec-b6d1-1d8eefe54e02" ,
142- "6b01e19f-fc2f-4ea7-b524-6f6c634aea63" ,
143- "b3950c28-8b64-49ed-bdfb-d83a4df39c96" ,
144- "f5098c7d-81f0-44d9-b0f7-3b8eadee5c34" ,
145- ]
146- )
147-
148- assert len (transactions ) == 7
149- assert references == expected_references
150-
151-
152- def test_ofx_file_with_multiple_transactions_filter_by_start_date (
153- db , request , bank_account , user
154- ):
155- ofx_file_path = request .path .parent / "data" / "cora-multiple-transactions.ofx"
156- with open (ofx_file_path , "r" ) as ofx_file :
157- ofx_importer = OFXImporter (ofx_file , bank_account , user )
158-
159- transactions = ofx_importer .run (start_date = datetime .date (2024 , 8 , 25 ))
160-
161- references = sorted ([transaction .reference for transaction in transactions ])
162- expected_references = sorted (
163- [
164- "69b66fe5-0360-466c-b2e5-08efc1768389" ,
165- "39221b44-f648-44ec-b6d1-1d8eefe54e02" ,
166- "6b01e19f-fc2f-4ea7-b524-6f6c634aea63" ,
167- ]
168- )
169-
170- assert len (transactions ) == 3
171- assert references == expected_references
172-
173-
174- def test_ofx_file_with_multiple_transactions_filter_by_end_date (
175- db , request , bank_account , user
176- ):
177- ofx_file_path = request .path .parent / "data" / "cora-multiple-transactions.ofx"
178- with open (ofx_file_path , "r" ) as ofx_file :
179- ofx_importer = OFXImporter (ofx_file , bank_account , user )
180-
181- transactions = ofx_importer .run (end_date = datetime .date (2024 , 8 , 25 ))
182-
183- references = sorted ([transaction .reference for transaction in transactions ])
184- expected_references = sorted (
185- [
186- "3825c888-1017-497d-bee2-c0737d5dafc0" ,
187- "63c41497-5e0b-4a3c-ada1-d9abebb0af39" ,
188- ]
189- )
190-
191- assert len (transactions ) == 2
192- assert references == expected_references
193-
194-
195- def test_ofx_file_with_multiple_transactions_filter_by_start_date_and_end_date (
196- db , request , bank_account , user
197- ):
198- ofx_file_path = request .path .parent / "data" / "cora-multiple-transactions.ofx"
199- with open (ofx_file_path , "r" ) as ofx_file :
200- ofx_importer = OFXImporter (ofx_file , bank_account , user )
201-
202- transactions = ofx_importer .run (
203- start_date = datetime .date (2024 , 8 , 24 ), end_date = datetime .date (2024 , 9 , 15 )
204- )
205-
206- references = sorted ([transaction .reference for transaction in transactions ])
207- expected_references = sorted (
208- [
209- "63c41497-5e0b-4a3c-ada1-d9abebb0af39" ,
210- "69b66fe5-0360-466c-b2e5-08efc1768389" ,
211- "39221b44-f648-44ec-b6d1-1d8eefe54e02" ,
212- ]
213- )
214-
215- assert len (transactions ) == 3
216- assert references == expected_references
217-
218-
21961@pytest .mark .parametrize (
22062 "ignored_memos,expected_references" ,
22163 [
0 commit comments