diff --git a/app/server/tests/test_views.py b/app/server/tests/test_views.py index 79fd7df3..829445b4 100644 --- a/app/server/tests/test_views.py +++ b/app/server/tests/test_views.py @@ -11,9 +11,8 @@ class TestUpload(TestCase): def setUp(self): self.username, self.password = 'user', 'pass' self.client = Client() - self.filepath = os.path.join(os.path.dirname(__file__), 'data/test.csv') - self.jsonpath = os.path.join(os.path.dirname(__file__), 'data/test.jsonl') - + self.csv_path = os.path.join(os.path.dirname(__file__), 'data/test.csv') + self.json_path = os.path.join(os.path.dirname(__file__), 'data/test.jsonl') def create_user(self): user = User.objects.create_user(username=self.username, password=self.password) @@ -31,7 +30,7 @@ class TestUpload(TestCase): return project - def test_create_doc_by_admin(self): + def test_upload_csv_by_admin(self): """ Ensure we can create a new document object by admin. """ @@ -39,7 +38,7 @@ class TestUpload(TestCase): project = self.create_project() project.users.add(user) - with open(self.filepath) as f: + with open(self.csv_path) as f: url = reverse('upload', args=[project.id]) self.client.login(username=self.username, password=self.password) response = self.client.post(url, {'file': f, 'format': 'csv'}) @@ -47,7 +46,7 @@ class TestUpload(TestCase): self.assertEqual(response.status_code, status.HTTP_302_FOUND) self.assertEqual(Document.objects.count(), 3) - def test_create_doc_by_user(self): + def test_upload_csv_by_user(self): """ Ensure we cannot create a new project object by user. """ @@ -55,7 +54,7 @@ class TestUpload(TestCase): project = self.create_project() project.users.add(user) - with open(self.filepath) as f: + with open(self.csv_path) as f: url = reverse('upload', args=[project.id]) self.client.login(username=self.username, password=self.password) response = self.client.post(url, {'file': f, 'format': 'csv'}) @@ -71,11 +70,10 @@ class TestUpload(TestCase): project = self.create_project() project.users.add(user) - with open(self.jsonpath, 'r') as f: + with open(self.json_path, 'r') as f: url = reverse('upload', args=[project.id]) self.client.login(username=self.username, password=self.password) response = self.client.post(url, {'file': f, 'format': 'json'}) - print(self.jsonpath) self.assertEqual(response.status_code, status.HTTP_302_FOUND) - self.assertEqual(Document.objects.count(), 18) \ No newline at end of file + self.assertEqual(Document.objects.count(), 18)