Fakultas Ilmu Komputer UI

Commit 3ce596a3 authored by Dave Nathanael's avatar Dave Nathanael
Browse files

[RED] Add test for csv export with filters

parent 7e1f0a7f
Pipeline #47923 failed with stages
in 5 minutes and 32 seconds
......@@ -181,8 +181,8 @@ class ExportableViewTest(APITestCase):
self.assertJSONEqual(response.content, data)
def test_export_investigation_data_to_csv_all(self):
url = "/exportables/investigation-cases-csv/"
def export_csv_test_util(self, filter):
url = "/exportables/investigation-cases-csv/" + filter
response = self.client.get(url)
self.assertEqual(response.status_code, status.HTTP_200_OK)
......@@ -197,4 +197,20 @@ class ExportableViewTest(APITestCase):
headers = body.pop(0)
self.assertEqual(headers, INVESTIGATION_CASE_RENDERER_FIELDS)
return body
def test_export_investigation_data_to_csv_all(self):
body = self.export_csv_test_util("")
self.assertEqual(len(body), 5)
def test_export_investigation_data_to_csv_filter_gender(self):
body = self.export_csv_test_util("?is_male=false")
self.assertEqual(len(body), 2)
def test_export_investigation_data_to_csv_filter_age(self):
body = self.export_csv_test_util("?age=21")
self.assertEqual(len(body), 2)
def test_export_investigation_data_to_csv_filter_district(self):
body = self.export_csv_test_util("?district=Beji")
self.assertEqual(len(body), 1)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment