Skip to content

Commit

Permalink
Add large_csv_upload test
Browse files Browse the repository at this point in the history
  • Loading branch information
DavisRayM committed Dec 11, 2019
1 parent 9c5b072 commit 04d1289
Show file tree
Hide file tree
Showing 2 changed files with 516 additions and 0 deletions.
16 changes: 16 additions & 0 deletions onadata/apps/api/tests/viewsets/test_xform_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1981,6 +1981,22 @@ def test_csv_import(self):
self.assertEqual(response.data.get('additions'), 9)
self.assertEqual(response.data.get('updates'), 0)

def test_large_csv_import(self):
with HTTMock(enketo_mock):
xls_path = os.path.join(settings.PROJECT_ROOT, "apps", "main",
"tests", "fixtures", "tutorial.xls")
self._publish_xls_form_to_project(xlsform_path=xls_path)
view = XFormViewSet.as_view({'post': 'csv_import'})
csv_import = fixtures_path('large_csv_upload.csv')
post_data = {'csv_file': csv_import}
request = self.factory.post('/', data=post_data, **self.extra)
response = view(request, pk=self.xform.id)

self.assertEqual(response.status_code, 200)
self.assertEqual(response.get('Cache-Control'), None)
self.assertEqual(response.data.get('additions'), 500)
self.assertEqual(response.data.get('updates'), 0)

@override_settings(CELERY_TASK_ALWAYS_EAGER=True)
@override_settings(CSV_FILESIZE_IMPORT_ASYNC_THRESHOLD=20)
def test_csv_import_async(self):
Expand Down
Loading

0 comments on commit 04d1289

Please sign in to comment.