From 4d113a691685b205074ebe765d897c6b26cfb56d Mon Sep 17 00:00:00 2001 From: Kuroshini Date: Fri, 27 Sep 2019 22:06:46 +0300 Subject: [PATCH] Fix all test --- apps/establishment/serializers/back.py | 2 +- apps/establishment/tests.py | 7 +++++++ apps/utils/tests.py | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/establishment/serializers/back.py b/apps/establishment/serializers/back.py index 788fa1e1..5a15aafc 100644 --- a/apps/establishment/serializers/back.py +++ b/apps/establishment/serializers/back.py @@ -22,7 +22,7 @@ class EstablishmentListCreateSerializer(EstablishmentBaseSerializer): emails = ContactEmailsSerializer(read_only=True, many=True, ) socials = SocialNetworkRelatedSerializers(read_only=True, many=True, ) slug = serializers.SlugField(required=True, allow_blank=False, max_length=50) - type = EstablishmentTypeSerializer(source='establishment_type') + type = EstablishmentTypeSerializer(source='establishment_type', read_only=True) class Meta: model = models.Establishment diff --git a/apps/establishment/tests.py b/apps/establishment/tests.py index 16d224b8..39e28861 100644 --- a/apps/establishment/tests.py +++ b/apps/establishment/tests.py @@ -6,6 +6,7 @@ from http.cookies import SimpleCookie from main.models import Currency from establishment.models import Establishment, EstablishmentType, Menu # Create your tests here. +from translation.models import Language class BaseTestCase(APITestCase): @@ -25,6 +26,12 @@ class BaseTestCase(APITestCase): self.establishment_type = EstablishmentType.objects.create(name="Test establishment type") + # Create lang object + Language.objects.create( + title='English', + locale='en-GB' + ) + class EstablishmentBTests(BaseTestCase): def test_establishment_CRUD(self): diff --git a/apps/utils/tests.py b/apps/utils/tests.py index 10af2a92..0eaf343d 100644 --- a/apps/utils/tests.py +++ b/apps/utils/tests.py @@ -95,6 +95,7 @@ class BaseAttributeTests(BaseTestCase): response_data = response.json() self.assertIn("id", response_data) + self.assertIsInstance(response_data['id'], int) employee = Employee.objects.get(id=response_data['id']) @@ -118,7 +119,7 @@ class BaseAttributeTests(BaseTestCase): 'name': 'Test new name' } - response = self.client.patch('/api/back/establishments/employees/1/', data=update_data) + response = self.client.patch(f'/api/back/establishments/employees/{employee.pk}/', data=update_data) self.assertEqual(response.status_code, status.HTTP_200_OK) employee.refresh_from_db()