Skip to content

Commit 9de4c9e

Browse files
committed
Fixed mock object for simplejson case
1 parent 5afd3f5 commit 9de4c9e

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

‎tests/unit/test_client.py‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import simplejson as json
12
from tests.integration.test_base import QuickbooksUnitTestCase
23

34
try:
@@ -141,7 +142,7 @@ def test_get_single_object(self, make_req):
141142

142143
@patch('quickbooks.client.QuickBooks.process_request')
143144
def test_make_request(self, process_request):
144-
process_request.return_value = MockResponse()
145+
process_request.return_value = MockResponseSimpleJson()
145146

146147
qb_client = client.QuickBooks()
147148
qb_client.company_id = "1234"
@@ -220,7 +221,7 @@ def test_download_pdf_not_authorized(self, process_request):
220221
@patch('quickbooks.client.QuickBooks.process_request')
221222
def test_make_request_file_closed(self, process_request):
222223
file_path = '/path/to/file.txt'
223-
process_request.return_value = MockResponse()
224+
process_request.return_value = MockResponseSimpleJson()
224225
with patch('builtins.open', mock_open(read_data=b'file content')) as mock_file:
225226
qb_client = client.QuickBooks(auth_client=self.auth_client)
226227
qb_client.make_request('POST',
@@ -253,6 +254,18 @@ def json(self):
253254
def content(self):
254255
return ''
255256

257+
class MockResponseSimpleJson:
258+
def __init__(self, json_data=None, status_code=200):
259+
self.json_data = json_data or {}
260+
self.status_code = status_code
261+
262+
@property
263+
def text(self):
264+
return json.dumps(self.json_data) # Ensure this uses simplejson if necessary
265+
266+
def json(self):
267+
return self.json_data
268+
256269

257270
class MockUnauthorizedResponse(object):
258271
@property

0 commit comments

Comments
 (0)