Skip to content

Commit 7a3e960

Browse files
committed
Fix unit tests
1 parent 978c2c2 commit 7a3e960

3 files changed

Lines changed: 12 additions & 9 deletions

File tree

tests/integration/test_invoice.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class InvoiceTest(QuickbooksTestCase):
1010

11-
def create_invoice(self, request_id=None):
11+
def create_invoice(self, customer, request_id=None):
1212
invoice = Invoice()
1313

1414
line = SalesItemLine()
@@ -21,15 +21,16 @@ def create_invoice(self, request_id=None):
2121
line.SalesItemLineDetail.ItemRef = item.to_ref()
2222
invoice.Line.append(line)
2323

24-
customer = Customer.all(max_results=1, qb=self.qb_client)[0]
2524
invoice.CustomerRef = customer.to_ref()
2625

2726
invoice.CustomerMemo = CustomerMemo()
2827
invoice.CustomerMemo.value = "Customer Memo"
2928
invoice.save(qb=self.qb_client, request_id=request_id)
29+
return invoice
3030

3131
def test_create(self):
32-
invoice = self.create_invoice()
32+
customer = Customer.all(max_results=1, qb=self.qb_client)[0]
33+
invoice = self.create_invoice(customer)
3334
query_invoice = Invoice.get(invoice.Id, qb=self.qb_client)
3435

3536
self.assertEquals(query_invoice.CustomerRef.name, customer.DisplayName)
@@ -38,16 +39,18 @@ def test_create(self):
3839
self.assertEquals(query_invoice.Line[0].Amount, 100.0)
3940

4041
def test_create_idempotence(self):
42+
customer = Customer.all(max_results=1, qb=self.qb_client)[0]
4143
sample_request_id = str(uuid.uuid4())
42-
invoice = self.create_invoice(request_id=sample_request_id)
43-
duplicate_invoice = self.create_invoice(request_id=sample_request_id)
44+
invoice = self.create_invoice(customer, request_id=sample_request_id)
45+
duplicate_invoice = self.create_invoice(customer, request_id=sample_request_id)
4446

4547
# Assert that both returned invoices have the same id
4648
self.assertEquals(invoice.Id, duplicate_invoice.Id)
4749

4850
def test_delete(self):
51+
customer = Customer.all(max_results=1, qb=self.qb_client)[0]
4952
# First create an invoice
50-
invoice = self.create_invoice()
53+
invoice = self.create_invoice(customer)
5154

5255
# Then delete
5356
invoice_id = invoice.Id

tests/unit/test_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def test_update_object_with_request_id(self, make_req):
124124
qb_client.update_object("Customer", "request_body", request_id="123")
125125

126126
url = "https://sandbox-quickbooks.api.intuit.com/v3/company/1234/customer"
127-
make_req.assert_called_with("POST", url, request_id="123")
127+
make_req.assert_called_with("POST", url, "request_body", file_path = None, request_id="123")
128128

129129
@patch('quickbooks.client.QuickBooks.get')
130130
def test_get_current_user(self, get):

tests/unit/test_mixins.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ class UpdateMixinTest(QuickbooksUnitTestCase):
227227
def test_save_create(self, create_object):
228228
department = Department()
229229
department.save(qb=self.qb_client)
230-
create_object.assert_called_once_with("Department", department.to_json())
230+
create_object.assert_called_once_with("Department", department.to_json(), request_id=None)
231231

232232
def test_save_create_with_qb(self):
233233
with patch.object(self.qb_client, 'create_object') as create_object:
@@ -242,7 +242,7 @@ def test_save_update(self, update_object):
242242
json = department.to_json()
243243

244244
department.save(qb=self.qb_client)
245-
update_object.assert_called_once_with("Department", json)
245+
update_object.assert_called_once_with("Department", json, request_id=None)
246246

247247
def test_save_update_with_qb(self):
248248
with patch.object(self.qb_client, 'update_object') as update_object:

0 commit comments

Comments
 (0)