From 17a4408baab7a7c23b5207b9992eac019f86aefd Mon Sep 17 00:00:00 2001 From: Hironsan Date: Tue, 31 Jul 2018 22:38:12 +0900 Subject: [PATCH] Add template for api test --- app/db.sqlite3 | Bin 258048 -> 258048 bytes app/server/tests/test_api.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 app/server/tests/test_api.py diff --git a/app/db.sqlite3 b/app/db.sqlite3 index 359340ddf38f95c1b451af72f6d3280db95cf8cf..06194aebf167e3a4e495dd3f06233321e54887f7 100644 GIT binary patch delta 336 zcmZp8z~AtIe}XjQmWeXXj9WG)+?>a6XkcY%Xk}`qXKr9@VrkgyF~8koKI3+e`Al86 z!qSaPGcB_Xi;S`}N)jv0k}8ucbIQt$%#6~FE6fc{a{a18EBwPlEB##Da-v+KvLmZ} zD}9Z;a)4q6zF9e0QMrMY{_cSWQ7(}tQ7)k-{^7n=elF7$>X{`OE2lS9GZ#l2L}djU zM`bxy_`63|`nvmNM`cBtMuqrg`-cSOM1^DK}IsMF>0wQPzv&u0$GEUd2VV2sycs_G%004tdX-EJ7 delta 207 zcmZp8z~AtIe}XjQhKVxHj2kv4+?>a6U}`Gkz5nW?x2v=H~P>a|(!n+=gT@s~oc< R<8+-GW~uFq=QGC!007!(K=}Xw diff --git a/app/server/tests/test_api.py b/app/server/tests/test_api.py new file mode 100644 index 00000000..066bac7c --- /dev/null +++ b/app/server/tests/test_api.py @@ -0,0 +1,28 @@ +from django.urls import reverse +from rest_framework import status +from rest_framework.test import APITestCase +from mixer.backend.django import mixer + + +class TestProjects(APITestCase): + + def setUp(self): + user = mixer.blend('auth.User') + self.project = mixer.blend('server.Project') + self.project.users.add(user) + self.client.force_login(user=user) + + def test_get_projects(self): + """ + Ensure we can get project objects. + """ + url = reverse('project-list') + response = self.client.get(url, format='json') + project = response.data[0] + self.assertEqual(response.status_code, status.HTTP_200_OK) + self.assertIsInstance(response.data, list) + self.assertEqual(project['id'], self.project.id) + self.assertEqual(project['name'], self.project.name) + self.assertEqual(project['description'], self.project.description) + self.assertEqual(project['project_type'], self.project.project_type) + self.assertEqual(project['image'], self.project.image)