# Path: app/timetables/factories.py
# class CourseFactory(DjangoModelFactory):
#     """Course model factory."""
# 
#     class Meta:
#         model = models.Course
# 
#     name = 'Appetizer'
#     sequence_order = 0
# 
# class DishFactory(TimestampFactory):
#     """Dish model factory."""
# 
#     class Meta:
#         model = models.Dish
# 
#     name = 'Coconut rice'
#     description = 'Some random description'
# 
# class MealFactory(DjangoModelFactory):
#     """Meal model factory."""
# 
#     class Meta:
#         model = models.Meal
# 
#     name = 'Breakfast'
#     start_time = datetime.time(9, 0, 0)
#     end_time = datetime.time(10, 0, 0)
# 
# class MenuItemFactory(TimestampFactory):
#     """MenuItem model factory."""
# 
#     class Meta:
#         model = models.MenuItem
# 
#     timetable = factory.SubFactory(TimetableFactory)
#     cycle_day = 2
#     meal = factory.SubFactory(MealFactory)
#     course = factory.SubFactory(CourseFactory)
#     dish = factory.SubFactory(DishFactory)
# 
# class VendorServiceFactory(DjangoModelFactory):
#     """VendorService model factory."""
# 
#     class Meta:
#         model = models.VendorService
# 
#     timetable = factory.SubFactory(TimetableFactory)
#     vendor = factory.SubFactory(VendorFactory)
#     start_date = datetime.date(2008, 1, 23)
#     end_date = datetime.date(2008, 12, 28)
# 
# 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 app.timetables.factories import (
    CourseFactory, DishFactory, MealFactory, MenuItemFactory,
    VendorServiceFactory,
)
from .utils import create_admin_account, make_request
        if vendor:
            query_args = 'timetable: "{}", vendor: "{}", date: "{}"'.format(
                timetable, vendor, date
            )
        else:
            query_args = 'timetable: "{}", date: "{}"'.format(timetable, date)

        query = '''query {servings(%s) {
                    dateServed
                    vendor {
                        name
                    }
                    menuItem {
                        cycleDay
                        meal {
                            name
                        }
                        course {
                            name
                            sequenceOrder
                        }
                        dish {
                            name
                        }
                        timetable {
                            name
                        }
                    }
                }}''' % (query_args)


# Path: app/timetables/factories.py
# class CourseFactory(DjangoModelFactory):
#     """Course model factory."""
# 
#     class Meta:
#         model = models.Course
# 
#     name = 'Appetizer'
#     sequence_order = 0
# 
# class DishFactory(TimestampFactory):
#     """Dish model factory."""
# 
#     class Meta:
#         model = models.Dish
# 
#     name = 'Coconut rice'
#     description = 'Some random description'
# 
# class MealFactory(DjangoModelFactory):
#     """Meal model factory."""
# 
#     class Meta:
#         model = models.Meal
# 
#     name = 'Breakfast'
#     start_time = datetime.time(9, 0, 0)
#     end_time = datetime.time(10, 0, 0)
# 
# class MenuItemFactory(TimestampFactory):
#     """MenuItem model factory."""
# 
#     class Meta:
#         model = models.MenuItem
# 
#     timetable = factory.SubFactory(TimetableFactory)
#     cycle_day = 2
#     meal = factory.SubFactory(MealFactory)
#     course = factory.SubFactory(CourseFactory)
#     dish = factory.SubFactory(DishFactory)
# 
# class VendorServiceFactory(DjangoModelFactory):
#     """VendorService model factory."""
# 
#     class Meta:
#         model = models.VendorService
# 
#     timetable = factory.SubFactory(TimetableFactory)
#     vendor = factory.SubFactory(VendorFactory)
#     start_date = datetime.date(2008, 1, 23)
#     end_date = datetime.date(2008, 12, 28)
# 
# 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_serving_api.py
from django.test import Client, TestCase
from app.timetables.factories import (
    CourseFactory, DishFactory, MealFactory, MenuItemFactory,
    VendorServiceFactory,
)
from .utils import create_admin_account, make_request

        if vendor:
            query_args = 'timetable: "{}", vendor: "{}", date: "{}"'.format(
                timetable, vendor, date
            )
        else:
            query_args = 'timetable: "{}", date: "{}"'.format(timetable, date)

        query = '''query {servings(%s) {
                    dateServed
                    vendor {
                        name
                    }
                    menuItem {
                        cycleDay
                        meal {
                            name
                        }
                        course {
                            name
                            sequenceOrder
                        }
                        dish {
                            name
                        }
                        timetable {
                            name
                        }
                    }
                }}''' % (query_args)


        return make_request(self.client, query)