Add establishment tests
This commit is contained in:
parent
2a79018f76
commit
49d2070544
|
|
@ -2,7 +2,10 @@ from rest_framework.test import APITestCase
|
|||
from account.models import User
|
||||
from rest_framework import status
|
||||
from http.cookies import SimpleCookie
|
||||
from establishment.models import Employee
|
||||
from establishment.models import Establishment, EstablishmentType, Employee
|
||||
|
||||
from rest_framework.reverse import reverse
|
||||
|
||||
# Create your tests here.
|
||||
|
||||
|
||||
|
|
@ -20,6 +23,29 @@ class BaseTestCase(APITestCase):
|
|||
'refresh_token': tokkens.get('refresh_token')})
|
||||
|
||||
|
||||
class EstablishmentTests(BaseTestCase):
|
||||
def test_establishment_CRD(self):
|
||||
response = self.client.get('/api/back/establishments/', format='json')
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
establishment_type = EstablishmentType.objects.create(name="Test establishment type")
|
||||
|
||||
data = {
|
||||
'name': 'Test establishment',
|
||||
'type_id': establishment_type.id,
|
||||
}
|
||||
|
||||
response = self.client.post('/api/back/establishments/', data=data, format='json')
|
||||
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
|
||||
print(response.json())
|
||||
|
||||
response = self.client.get('/api/back/establishments/1/', format='json')
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
response = self.client.delete('/api/back/establishments/1/', format='json')
|
||||
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
|
||||
|
||||
|
||||
class EmployeeTests(BaseTestCase):
|
||||
def test_employee_CRD(self):
|
||||
response = self.client.get('/api/back/establishments/employees/', format='json')
|
||||
|
|
@ -39,6 +65,3 @@ class EmployeeTests(BaseTestCase):
|
|||
response = self.client.delete('/api/back/establishments/employees/1/', format='json')
|
||||
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user