# 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
                    }
                }
            }
        ''' % (create_response['dish']['id'])
        expected = {
            'dish': {
                'id': create_response['dish']['id'],
                'name': 'rice edited'
            }
        }
        response = make_request(self.client, query, 'POST')
        self.assertEqual(expected, response)

        # Update with invalid id
        query = '''
            mutation{
                updateDish(
                    input: {
                        id: "%s",
                        name: "rice edited"
                    }
                )
                {
                    dish{
                        id,
                        name
                    }
                }
            }
        ''' % ('wrong-id')

# 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

                    }
                }
            }
        ''' % (create_response['dish']['id'])
        expected = {
            'dish': {
                'id': create_response['dish']['id'],
                'name': 'rice edited'
            }
        }
        response = make_request(self.client, query, 'POST')
        self.assertEqual(expected, response)

        # Update with invalid id
        query = '''
            mutation{
                updateDish(
                    input: {
                        id: "%s",
                        name: "rice edited"
                    }
                )
                {
                    dish{
                        id,
                        name
                    }
                }
            }
        ''' % ('wrong-id')

        self.assertEqual({'dish': None}, make_request(self.client, query, 'POST'))