Add tests to guide
This commit is contained in:
parent
aedcd795a9
commit
b4a2893fcd
|
|
@ -1,11 +1,11 @@
|
|||
import json
|
||||
import json, pytz
|
||||
from datetime import datetime
|
||||
from rest_framework.test import APITestCase
|
||||
from account.models import User
|
||||
from rest_framework import status
|
||||
from http.cookies import SimpleCookie
|
||||
|
||||
from collection.models import Collection
|
||||
from collection.models import Collection, Guide
|
||||
from location.models import Country
|
||||
|
||||
# Create your tests here.
|
||||
|
|
@ -13,7 +13,7 @@ from location.models import Country
|
|||
|
||||
class BaseTestCase(APITestCase):
|
||||
|
||||
def setUpT(self):
|
||||
def setUp(self):
|
||||
self.username = 'sedragurda'
|
||||
self.password = 'sedragurdaredips19'
|
||||
self.email = 'sedragurda@desoz.com'
|
||||
|
|
@ -24,7 +24,8 @@ class BaseTestCase(APITestCase):
|
|||
tokkens = User.create_jwt_tokens(self.user)
|
||||
self.client.cookies = SimpleCookie(
|
||||
{'access_token': tokkens.get('access_token'),
|
||||
'refresh_token': tokkens.get('refresh_token')})
|
||||
'refresh_token': tokkens.get('refresh_token'),
|
||||
'country_code': 'en'})
|
||||
|
||||
|
||||
class CollectionListTests(BaseTestCase):
|
||||
|
|
@ -42,53 +43,40 @@ class CollectionDetailTests(BaseTestCase):
|
|||
if not country:
|
||||
country = Country.objects.create(
|
||||
name=json.dumps({"en-GB": "Test country"}),
|
||||
code="test"
|
||||
code="en"
|
||||
)
|
||||
|
||||
self.collection = Collection.objects.create(
|
||||
name='Test collection',
|
||||
is_publish=True,
|
||||
start=datetime.now(),
|
||||
end=datetime.now(),
|
||||
start=datetime.now(pytz.utc),
|
||||
end=datetime.now(pytz.utc),
|
||||
country=country
|
||||
)
|
||||
|
||||
def test_collection_detail_Read(self):
|
||||
response = self.client.get(f'/api/web/collections/{self.collection.id}/', format='json')
|
||||
response = self.client.get(f'/api/web/collections/{self.collection.id}/establishments/?country_code=en',
|
||||
format='json')
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
|
||||
class CollectionGuideTests(CollectionDetailTests):
|
||||
|
||||
# data = {
|
||||
# 'name': 'Test collection',
|
||||
#
|
||||
# }
|
||||
#
|
||||
# response = self.client.post('/api/web/collections/', data=data, format='json')
|
||||
# self.assertEqual(response.status_code, status.HTTP_201_CREATED)
|
||||
#
|
||||
# establishment = response.json()
|
||||
#
|
||||
# response = self.client.get(f'/api/back/establishments/{establishment["id"]}/', format='json')
|
||||
# self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
#
|
||||
# update_data = {
|
||||
# 'name': 'Test new establishment'
|
||||
# }
|
||||
#
|
||||
# response = self.client.patch(f'/api/back/establishments/{establishment["id"]}/', data=update_data)
|
||||
# self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
#
|
||||
# response = self.client.delete(f'/api/back/establishments/{establishment["id"]}/', format='json')
|
||||
# self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
|
||||
def test_guide_list_Read(self):
|
||||
response = self.client.get('/api/web/collections/guides/', format='json')
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
|
||||
# Class to test childs
|
||||
# class ChildTestCase(BaseTestCase):
|
||||
# def setUp(self):
|
||||
# super().setUp()
|
||||
# self.establishment = Establishment.objects.create(
|
||||
# name="Test establishment",
|
||||
# establishment_type_id=self.establishment_type.id,
|
||||
# is_publish=True
|
||||
# )
|
||||
class CollectionGuideDetailTests(CollectionDetailTests):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.guide = Guide.objects.create(
|
||||
collection=self.collection,
|
||||
start=datetime.now(pytz.utc),
|
||||
end=datetime.now(pytz.utc)
|
||||
)
|
||||
|
||||
def test_guide_detail_Read(self):
|
||||
response = self.client.get(f'/api/web/collections/guides/{self.guide.id}/', format='json')
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user