Browse Source

move ExampleSerializer tests to test_document.py

pull/1473/head
youichiro 3 years ago
parent
commit
94ce5e6685
2 changed files with 9 additions and 27 deletions
  1. 10
      backend/api/tests/api/test_document.py
  2. 26
      backend/api/tests/test_serializers.py

10
backend/api/tests/api/test_document.py

@ -12,7 +12,7 @@ class TestExampleListAPI(CRUDMixin):
def setUp(self):
self.project = prepare_project(task=DOCUMENT_CLASSIFICATION)
self.non_member = make_user()
make_doc(self.project.item)
self.example = make_doc(self.project.item)
self.data = {'text': 'example'}
self.url = reverse(viewname='example_list', args=[self.project.item.id])
@ -41,6 +41,14 @@ class TestExampleListAPI(CRUDMixin):
def test_denies_unauthenticated_user_to_create_doc(self):
self.assert_create(expected=status.HTTP_403_FORBIDDEN)
def test_is_confirmed(self):
make_example_state(self.example, self.project.users[0])
response = self.assert_fetch(self.project.users[0], status.HTTP_200_OK)
self.assertTrue(response.data['results'][0]['is_confirmed'])
def test_is_not_confirmed(self):
response = self.assert_fetch(self.project.users[0], status.HTTP_200_OK)
self.assertFalse(response.data['results'][0]['is_confirmed'])
class TestExampleListFilter(CRUDMixin):

26
backend/api/tests/test_serializers.py

@ -1,26 +0,0 @@
from rest_framework.test import APITestCase
from ..serializers import ExampleSerializer
from .api.utils import make_doc, make_example_state, prepare_project
class TestExampleStateSerializer(APITestCase):
def setUp(self):
self.project = prepare_project(task='DocumentClassification')
self.example = make_doc(self.project.item)
def test_in_is_confirmed(self):
serializer = ExampleSerializer(instance=self.example)
self.assertIn('is_confirmed', serializer.data)
def test_is_not_confirmed(self):
serializer = ExampleSerializer(instance=self.example)
is_confirmed = serializer.data['is_confirmed']
self.assertFalse(is_confirmed)
def test_is_confirmed(self):
make_example_state(self.example, self.project.users[0])
serializer = ExampleSerializer(instance=self.example)
is_confirmed = serializer.data['is_confirmed']
self.assertTrue(is_confirmed)
Loading…
Cancel
Save