@@ -42,7 +42,7 @@ def test_valid_but_empty_invoice_file(
4242 invoice_file_path = (
4343 request .path .parent / "data" / "empty-cora-credit-card-invoice.csv"
4444 )
45- with open (invoice_file_path , "r " ) as invoice_file :
45+ with open (invoice_file_path , "rb " ) as invoice_file :
4646 importer = CoraCreditCardInvoiceImporter (invoice_file )
4747 transactions = importer .get_transactions ()
4848 assert transactions == []
@@ -51,7 +51,7 @@ def test_invalid_invoice_file(self, db, request):
5151 invoice_file_path = (
5252 request .path .parent / "data" / "invalid-cora-credit-card-invoice.csv"
5353 )
54- with open (invoice_file_path , "r " ) as invoice_file :
54+ with open (invoice_file_path , "rb " ) as invoice_file :
5555 importer = CoraCreditCardInvoiceImporter (invoice_file )
5656
5757 with pytest .raises (InvalidCoraCreditCardInvoice ):
@@ -65,7 +65,7 @@ def test_one_transaction_excluding_existing_false(
6565 / "data"
6666 / "cora-credit-card-invoice-one-transaction.csv"
6767 )
68- with open (invoice_file_path , "r " ) as invoice_file :
68+ with open (invoice_file_path , "rb " ) as invoice_file :
6969 importer = CoraCreditCardInvoiceImporter (invoice_file )
7070 transactions = importer .get_transactions ()
7171
@@ -81,58 +81,87 @@ def test_one_transaction_excluding_existing_false(
8181 assert transactions [0 ].source == "cora-credit-card-invoice-importer"
8282 assert transactions [0 ].created_by == user
8383
84- def test_one_transaction_excluding_existing_true (self , db , request ):
84+ def test_one_transaction_excluding_existing_true (
85+ self , db , request , cora_credit_card_bank_account
86+ ):
8587 baker .make (
8688 Transaction ,
8789 date = datetime .date (2026 , 2 , 21 ),
8890 description = "BACKBLAZE INC" ,
8991 amount = decimal .Decimal ("-8.91" ),
92+ bank_account = cora_credit_card_bank_account ,
9093 )
9194
9295 invoice_file_path = (
9396 request .path .parent
9497 / "data"
9598 / "cora-credit-card-invoice-one-transaction.csv"
9699 )
97- with open (invoice_file_path , "r " ) as invoice_file :
100+ with open (invoice_file_path , "rb " ) as invoice_file :
98101 importer = CoraCreditCardInvoiceImporter (invoice_file )
99102 transactions = importer .get_transactions (exclude_existing = True )
100103 assert len (transactions ) == 0
101104
102- def test_two_transactions_excluding_existing_true (self , db , request ):
105+ def test_one_transaction_from_different_bank_account (
106+ self , db , request , cora_credit_card_bank_account
107+ ):
108+ baker .make (
109+ Transaction ,
110+ date = datetime .date (2026 , 2 , 21 ),
111+ description = "BACKBLAZE INC" ,
112+ amount = decimal .Decimal ("-8.91" ),
113+ )
114+
115+ invoice_file_path = (
116+ request .path .parent
117+ / "data"
118+ / "cora-credit-card-invoice-one-transaction.csv"
119+ )
120+ with open (invoice_file_path , "rb" ) as invoice_file :
121+ importer = CoraCreditCardInvoiceImporter (invoice_file )
122+ transactions = importer .get_transactions (exclude_existing = True )
123+ assert len (transactions ) == 1
124+
125+ def test_two_transactions_excluding_existing_true (
126+ self , db , request , cora_credit_card_bank_account
127+ ):
103128 baker .make (
104129 Transaction ,
105130 date = datetime .date (2026 , 2 , 21 ),
106131 description = "BACKBLAZE INC" ,
107132 amount = decimal .Decimal ("-8.91" ),
133+ bank_account = cora_credit_card_bank_account ,
108134 )
109135
110136 invoice_file_path = (
111137 request .path .parent
112138 / "data"
113139 / "cora-credit-card-invoice-two-transactions.csv"
114140 )
115- with open (invoice_file_path , "r " ) as invoice_file :
141+ with open (invoice_file_path , "rb " ) as invoice_file :
116142 importer = CoraCreditCardInvoiceImporter (invoice_file )
117143 transactions = importer .get_transactions (exclude_existing = True )
118144
119145 assert len (transactions ) == 1
120146 assert transactions [0 ].description == "VULTR BY CONSTANT"
121147
122- def test_two_transactions_excluding_existing_false (self , db , request ):
148+ def test_two_transactions_excluding_existing_false (
149+ self , db , request , cora_credit_card_bank_account
150+ ):
123151 baker .make (
124152 Transaction ,
125153 date = datetime .date (2026 , 2 , 21 ),
126154 description = "BACKBLAZE INC" ,
127155 amount = decimal .Decimal ("-8.91" ),
156+ bank_account = cora_credit_card_bank_account ,
128157 )
129158
130159 invoice_file_path = (
131160 request .path .parent
132161 / "data"
133162 / "cora-credit-card-invoice-two-transactions.csv"
134163 )
135- with open (invoice_file_path , "r " ) as invoice_file :
164+ with open (invoice_file_path , "rb " ) as invoice_file :
136165 importer = CoraCreditCardInvoiceImporter (invoice_file )
137166 transactions = importer .get_transactions (exclude_existing = False )
138167
@@ -173,7 +202,7 @@ def test_transactions_filtered_by_date_range(
173202 / "data"
174203 / "cora-credit-card-invoice-multiple-transactions.csv"
175204 )
176- with open (invoice_file_path , "r " ) as invoice_file :
205+ with open (invoice_file_path , "rb " ) as invoice_file :
177206 importer = CoraCreditCardInvoiceImporter (invoice_file )
178207 transactions = importer .get_transactions (
179208 start_date = start_date , end_date = end_date
0 commit comments