Fix plate tests
Add menu tests
This commit is contained in:
parent
014931d2c4
commit
2f74c63fd9
|
|
@ -1,8 +1,10 @@
|
||||||
|
import json
|
||||||
from rest_framework.test import APITestCase
|
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
|
from main.models import Currency
|
||||||
|
from establishment.models import Establishment, EstablishmentType, Menu
|
||||||
|
|
||||||
# Create your tests here.
|
# Create your tests here.
|
||||||
|
|
||||||
|
|
@ -138,14 +140,22 @@ class SocialTests(ChildTestCase):
|
||||||
|
|
||||||
|
|
||||||
class PlatesTests(ChildTestCase):
|
class PlatesTests(ChildTestCase):
|
||||||
def test_plates_CRD(self):
|
def test_plate_CRD(self):
|
||||||
response = self.client.get('/api/back/establishments/plates/', format='json')
|
response = self.client.get('/api/back/establishments/plates/', format='json')
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
|
|
||||||
|
menu = Menu.objects.create(
|
||||||
|
category=json.dumps({"en-GB": "Test category"}),
|
||||||
|
establishment=self.establishment
|
||||||
|
)
|
||||||
|
currency = Currency.objects.create(name="Test currency")
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'title': "Test social",
|
'name': json.dumps({"en-GB": "Test plate"}),
|
||||||
'url': 'https://testsocial.com',
|
'establishment': self.establishment.id,
|
||||||
'establishment': self.establishment.id
|
'price': 10,
|
||||||
|
'menu': menu.id,
|
||||||
|
'currency_id': currency.id
|
||||||
}
|
}
|
||||||
|
|
||||||
response = self.client.post('/api/back/establishments/plates/', data=data)
|
response = self.client.post('/api/back/establishments/plates/', data=data)
|
||||||
|
|
@ -157,3 +167,23 @@ class PlatesTests(ChildTestCase):
|
||||||
|
|
||||||
response = self.client.delete('/api/back/establishments/plates/1/')
|
response = self.client.delete('/api/back/establishments/plates/1/')
|
||||||
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
|
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
|
||||||
|
|
||||||
|
|
||||||
|
class MenusTests(ChildTestCase):
|
||||||
|
def test_menu_CRD(self):
|
||||||
|
response = self.client.get('/api/back/establishments/menus/', format='json')
|
||||||
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
|
|
||||||
|
data = {
|
||||||
|
'category': json.dumps({"en-GB": "Test category"}),
|
||||||
|
'establishment': self.establishment.id
|
||||||
|
}
|
||||||
|
|
||||||
|
response = self.client.post('/api/back/establishments/menus/', data=data)
|
||||||
|
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
|
||||||
|
|
||||||
|
response = self.client.get('/api/back/establishments/menus/1/', format='json')
|
||||||
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
|
|
||||||
|
response = self.client.delete('/api/back/establishments/menus/1/')
|
||||||
|
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user