Browse Source

Ensure fields are consistent

pull/532/head
Clemens Wolff 4 years ago
parent
commit
b0f6308d97
2 changed files with 17 additions and 6 deletions
  1. 9
      app/api/serializers.py
  2. 14
      app/api/tests/test_api.py

9
app/api/serializers.py

@ -113,8 +113,7 @@ class TextClassificationProjectSerializer(ProjectSerializer):
class Meta: class Meta:
model = TextClassificationProject model = TextClassificationProject
fields = ('id', 'name', 'description', 'guideline', 'users', 'current_users_role', 'project_type', 'image',
'updated_at', 'randomize_document_order')
fields = ProjectSerializer.Meta.fields
read_only_fields = ProjectSerializer.Meta.read_only_fields read_only_fields = ProjectSerializer.Meta.read_only_fields
@ -122,8 +121,7 @@ class SequenceLabelingProjectSerializer(ProjectSerializer):
class Meta: class Meta:
model = SequenceLabelingProject model = SequenceLabelingProject
fields = ('id', 'name', 'description', 'guideline', 'users', 'current_users_role', 'project_type', 'image',
'updated_at', 'randomize_document_order')
fields = ProjectSerializer.Meta.fields
read_only_fields = ProjectSerializer.Meta.read_only_fields read_only_fields = ProjectSerializer.Meta.read_only_fields
@ -131,8 +129,7 @@ class Seq2seqProjectSerializer(ProjectSerializer):
class Meta: class Meta:
model = Seq2seqProject model = Seq2seqProject
fields = ('id', 'name', 'description', 'guideline', 'users', 'current_users_role', 'project_type', 'image',
'updated_at', 'randomize_document_order')
fields = ProjectSerializer.Meta.fields
read_only_fields = ProjectSerializer.Meta.read_only_fields read_only_fields = ProjectSerializer.Meta.read_only_fields

14
app/api/tests/test_api.py

@ -111,6 +111,20 @@ class TestProjectListAPI(APITestCase):
password=self.super_user_pass) password=self.super_user_pass)
response = self.client.post(self.url, format='json', data=self.data) response = self.client.post(self.url, format='json', data=self.data)
self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(response.status_code, status.HTTP_201_CREATED)
self.assertFalse(response.json().get('collaborative_annotation'))
self.assertFalse(response.json().get('randomize_document_order'))
def test_allows_superuser_to_create_project_with_flags(self):
self.client.login(username=self.super_user_name,
password=self.super_user_pass)
response = self.client.post(self.url, format='json', data=dict(
collaborative_annotation=True,
randomize_document_order=True,
**self.data,
))
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
self.assertTrue(response.json().get('collaborative_annotation'))
self.assertTrue(response.json().get('randomize_document_order'))
def test_disallows_project_member_to_create_project(self): def test_disallows_project_member_to_create_project(self):
self.client.login(username=self.main_project_member_name, self.client.login(username=self.main_project_member_name,

Loading…
Cancel
Save