Add phone tests

This commit is contained in:
littlewolf 2019-09-20 14:49:04 +03:00
parent 00d8f09881
commit ee93905556

View File

@ -2,9 +2,7 @@ from rest_framework.test import APITestCase
from account.models import User from account.models import User
from rest_framework import status from rest_framework import status
from http.cookies import SimpleCookie from http.cookies import SimpleCookie
from establishment.models import Establishment, EstablishmentType, Employee from establishment.models import Establishment, EstablishmentType
from rest_framework.reverse import reverse
# Create your tests here. # Create your tests here.
@ -90,3 +88,28 @@ class EmailTests(BaseTestCase):
response = self.client.delete('/api/back/establishments/emails/1/') response = self.client.delete('/api/back/establishments/emails/1/')
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT) self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
class PhoneTests(BaseTestCase):
def test_phone_CRD(self):
response = self.client.get('/api/back/establishments/phones/', format='json')
self.assertEqual(response.status_code, status.HTTP_200_OK)
establishment = Establishment.objects.create(
name="Test establishment",
establishment_type_id=self.establishment_type.id
)
data = {
'phone': "+79999999999",
'establishment': establishment.id
}
response = self.client.post('/api/back/establishments/phones/', data=data)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
response = self.client.get('/api/back/establishments/phones/1/', format='json')
self.assertEqual(response.status_code, status.HTTP_200_OK)
response = self.client.delete('/api/back/establishments/phones/1/')
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)