Expect bulk results under responses key

This commit is contained in:
Alan Hamlett 2017-11-24 16:10:15 -08:00
parent 5554f3c9dd
commit 4c7b49a28c
4 changed files with 18 additions and 18 deletions

View file

@ -527,7 +527,7 @@ class ArgumentsTestCase(TestCase):
logging.disable(logging.NOTSET)
response = CustomResponse()
response.response_text = '[[{"id":1},201], [{"id":1},201]]'
response.response_text = '{"responses": [[null, 201], [null,201]]}'
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
now1 = u(int(time.time()))
@ -590,7 +590,7 @@ class ArgumentsTestCase(TestCase):
logging.disable(logging.NOTSET)
response = CustomResponse()
response.response_text = '[[{"id":1},201], [{"id":1},201]]'
response.response_text = '{"responses": [[null, 201], [null,201]]}'
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
now1 = u(int(time.time()))
@ -653,7 +653,7 @@ class ArgumentsTestCase(TestCase):
logging.disable(logging.NOTSET)
response = CustomResponse()
response.response_text = '[[{"id":1},201], [{"id":1},201]]'
response.response_text = '{"responses": [[null, 201], [null,201]]}'
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
with TemporaryDirectory() as tempdir:
@ -717,7 +717,7 @@ class ArgumentsTestCase(TestCase):
logging.disable(logging.NOTSET)
response = CustomResponse()
response.response_text = '[[{"id":1},201], [{"id":1},201]]'
response.response_text = '{"responses": [[null, 201], [null,201]]}'
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
with TemporaryDirectory() as tempdir:
@ -814,7 +814,7 @@ class ArgumentsTestCase(TestCase):
logging.disable(logging.NOTSET)
response = CustomResponse()
response.response_text = '[[{"id":1},201], [{"id":1},201]]'
response.response_text = '{"responses": [[null, 201], [null,201]]}'
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
now1 = u(int(time.time()))
@ -880,7 +880,7 @@ class ArgumentsTestCase(TestCase):
logging.disable(logging.NOTSET)
response = CustomResponse()
response.response_text = '[[{"id":1},201], [{"id":1},201]]'
response.response_text = '{"responses": [[null, 201], [null,201]]}'
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
now1 = u(int(time.time()))

View file

@ -84,7 +84,7 @@ class OfflineQueueTestCase(TestCase):
execute(args)
response = CustomResponse()
response.response_text = '[[{"id":1},201], [{"id":1},201], [{"id":1},201]]'
response.response_text = '{"responses": [[null,201], [null,201], [null,201]]}'
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
execute(args)
@ -124,7 +124,7 @@ class OfflineQueueTestCase(TestCase):
args = ['--file', entity3, '--config', config, '--time', now3, '--project', project3]
response = CustomResponse()
response.response_text = '[[{"id":1},201], [{"id":1},201], [{"id":1},201]]'
response.response_text = '{"responses": [[null,201], [null,201], [null,201]]}'
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
execute(args)
@ -190,7 +190,7 @@ class OfflineQueueTestCase(TestCase):
response = CustomResponse()
response.response_code = 202
response.response_text = '[[{"id":1},201], [{"error":"error 2"},500], [{"id":3},201], [{"error":4},500]]'
response.response_text = '{"responses": [[null,201], [null,500], [null,201], [null, 500]]}'
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
with mock.patch('wakatime.main.sys.stdin') as mock_stdin:
@ -273,7 +273,7 @@ class OfflineQueueTestCase(TestCase):
response = CustomResponse()
response.response_code = 202
response.response_text = '[[{"id":1},201], [{"error":"error 2"},500], [{"id":3},201], [{"error":4},500]]'
response.response_text = '{"responses": [[null,201], [null,500], [null,201], [null, 500]]}'
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
with mock.patch('wakatime.main.sys.stdin') as mock_stdin:
@ -328,7 +328,7 @@ class OfflineQueueTestCase(TestCase):
response = CustomResponse()
response.response_code = 202
response.response_text = '[[{"id":1},201], [{"id":3},201]]'
response.response_text = '{"responses": [[null,201], [null,201]]}'
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
with mock.patch('wakatime.main.sys.stdin') as mock_stdin:
@ -390,7 +390,7 @@ class OfflineQueueTestCase(TestCase):
response = CustomResponse()
response.second_response_code = 401
response.limit = 2
response.response_text = '[[{"id":1},201], [{"id":1},201], [{"id":1},201]]'
response.response_text = '{"responses": [[null,201], [null,201], [null,201]]}'
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
retval = execute(args)
@ -436,7 +436,7 @@ class OfflineQueueTestCase(TestCase):
response = CustomResponse()
response.second_response_code = 500
response.limit = 2
response.response_text = '[[{"id":1},201], [{"id":1},201], [{"id":1},201]]'
response.response_text = '{"responses": [[null,201], [null,201], [null,201]]}'
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
retval = execute(args)
@ -751,7 +751,7 @@ class OfflineQueueTestCase(TestCase):
mock_db_file.return_value = fh.name
response = CustomResponse()
response.response_text = '[[{id":1}]]'
response.response_text = '{"responses": [[{id":1},201]]}'
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
now = u(int(time.time()))
@ -779,7 +779,7 @@ class OfflineQueueTestCase(TestCase):
mock_db_file.return_value = fh.name
response = CustomResponse()
response.response_text = '[0]'
response.response_text = '{"responses": [1]}'
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
now = u(int(time.time()))
@ -807,7 +807,7 @@ class OfflineQueueTestCase(TestCase):
mock_db_file.return_value = fh.name
response = CustomResponse()
response.response_text = '[[{"id":1}]]'
response.response_text = '{"responses": [[{"id":1}]]}'
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
now = u(int(time.time()))

View file

@ -233,7 +233,7 @@ class DynamicIterable(object):
class CustomResponse(Response):
response_code = 201
response_text = '[[{"id":1},201]]'
response_text = '{"responses": [[null,201]]}'
limit = 0
second_response_code = 0
second_response_text = None

View file

@ -210,7 +210,7 @@ def _get_results(response):
results = []
if response is not None:
try:
results = response.json()
results = response.json()['responses']
except:
log.traceback(logging.WARNING)
return results