# Path: app/api/tests/utils.py
# def create_admin_account():
#     return User.objects.create_superuser(*admin_test_credentials)
# 
# def make_request(client, query, method='GET'):
#     header = {
#         'HTTP_X_TAVERNATOKEN': obtain_api_key(client)
#     }
# 
#     if method == 'GET':
#         return client.get(endpoint, data={'query': query}, **header).json()
# 
#     if method == 'POST':
#         return client.post(endpoint, data={'query': query}, **header).json()


from django.test import Client, TestCase
from .utils import create_admin_account, make_request
    def test_retrieval_of_multiple_dish_objects_ordering_by_id(self):
        self.create_multiple_dishes()
        records = [
            self.dishes[0][0],
            self.dishes[1][0],
            self.dishes[2][0]
        ]

        self.ordering_test_helper('id', records)

    def test_retrieval_of_multiple_dish_objects_ordering_by_name(self):
        self.create_multiple_dishes()
        records = [
            self.dishes[1][0],
            self.dishes[2][0],
            self.dishes[0][0]
        ]

        self.ordering_test_helper('name', records)

    def test_update_of_dish_object(self):
        # Update with valid id
        create_response = self.create_dish(self.data['name'], self.data['description'])
        query = '''
            mutation{
                updateDish(
                    input: {
                        id: "%s",
                        name: "rice edited"
                    }

# Path: app/api/tests/utils.py
# def create_admin_account():
#     return User.objects.create_superuser(*admin_test_credentials)
# 
# def make_request(client, query, method='GET'):
#     header = {
#         'HTTP_X_TAVERNATOKEN': obtain_api_key(client)
#     }
# 
#     if method == 'GET':
#         return client.get(endpoint, data={'query': query}, **header).json()
# 
#     if method == 'POST':
#         return client.post(endpoint, data={'query': query}, **header).json()


# Path: app/api/tests/test_dish_api.py
from django.test import Client, TestCase
from .utils import create_admin_account, make_request

    def test_retrieval_of_multiple_dish_objects_ordering_by_id(self):
        self.create_multiple_dishes()
        records = [
            self.dishes[0][0],
            self.dishes[1][0],
            self.dishes[2][0]
        ]

        self.ordering_test_helper('id', records)

    def test_retrieval_of_multiple_dish_objects_ordering_by_name(self):
        self.create_multiple_dishes()
        records = [
            self.dishes[1][0],
            self.dishes[2][0],
            self.dishes[0][0]
        ]

        self.ordering_test_helper('name', records)

    def test_update_of_dish_object(self):
        # Update with valid id
        create_response = self.create_dish(self.data['name'], self.data['description'])
        query = '''
            mutation{
                updateDish(
                    input: {
                        id: "%s",
                        name: "rice edited"
                    }

                )