Skip to content

Commit 227d3be

Browse files
committed
Added test and increased default batch size to 5000
1 parent 526bc70 commit 227d3be

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

maproulette/api/task.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ def get_task_history(self, task_id):
3030
endpoint=f"/task/{task_id}/history")
3131
return response
3232

33-
def create_tasks(self, data, batch_size=100):
33+
def create_tasks(self, data, batch_size=5000):
3434
"""Method to create a batch of tasks using the specified batch_size.
3535
3636
:param data: a JSON input containing task details
37-
:param batch_size: the number of tasks to post per API call. The default is 100.
37+
:param batch_size: the number of tasks to post per API call. The default is 5000.
3838
:type batch_size: int
3939
:returns: the API response from the POST request
4040
"""

tests/test_task_api.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,15 @@ def test_get_task_comments(self, mock_request, api_instance=api):
9191
mock_request.return_value.status_code = '200'
9292
response = api_instance.get_task_comments(task_id)
9393
self.assertEqual(response['status'], '200')
94+
95+
def test_batch_generator(self, api_instance=api):
96+
97+
batch_size = 10
98+
test_length = 1234
99+
test_list = [i for i in range(test_length)]
100+
running_total = 0
101+
for chunk in api_instance.batch_generator(test_list, batch_size):
102+
running_total += len(chunk)
103+
self.assertIsInstance(chunk, list)
104+
self.assertLessEqual(len(chunk), batch_size)
105+
self.assertEqual(test_length, running_total)

0 commit comments

Comments
 (0)