# 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()


import datetime
from django.test import Client, TestCase
from .utils import create_admin_account, make_request

    def test_deletion_of_meal_object(self):
        # Delete with valid id
        create_response = self.create_meal(self.data['name'],
                                           self.data['start_time'],
                                           self.data['end_time'])
        query = '''
            mutation{
                deleteMeal(input: {id: "%s"}){
                    meal{
                        name
                    }
                }
            }
        ''' % (create_response['meal']['id'])
        expected = {
            'meal': {
                "name": self.data['name']
            }
        }
        response = make_request(self.client, query, 'POST')
        self.assertEqual(expected, response)
        self.assertEqual({'meal': None}, self.retrieve_meal(create_response['meal']['id']))

        # Delete with invalid id
        query = '''
            mutation{
                deleteMeal(input: {id: "%s"}){
                    meal{
                        name

# 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_meal_api.py
import datetime
from django.test import Client, TestCase
from .utils import create_admin_account, make_request


    def test_deletion_of_meal_object(self):
        # Delete with valid id
        create_response = self.create_meal(self.data['name'],
                                           self.data['start_time'],
                                           self.data['end_time'])
        query = '''
            mutation{
                deleteMeal(input: {id: "%s"}){
                    meal{
                        name
                    }
                }
            }
        ''' % (create_response['meal']['id'])
        expected = {
            'meal': {
                "name": self.data['name']
            }
        }
        response = make_request(self.client, query, 'POST')
        self.assertEqual(expected, response)
        self.assertEqual({'meal': None}, self.retrieve_meal(create_response['meal']['id']))

        # Delete with invalid id
        query = '''
            mutation{
                deleteMeal(input: {id: "%s"}){
                    meal{
                        name

                    }