# 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



class ServingApiTest(TestCase):
    """Tests for Serving API."""

    def setUp(self):
        self.vendor_service = VendorServiceFactory(start_date=None, end_date=None)
        self.timetable = self.vendor_service.timetable
        self.vendor = self.vendor_service.vendor
        self.date = self.timetable.ref_cycle_date

        meal = MealFactory()
        course = CourseFactory(name='main')
        dish_names = ['Quaker Oat and Moi-moi', 'Bread and Egg', 'Apples']
        self.menu_items = []
        for dish_name in dish_names:
            dish = DishFactory(name=dish_name)

# 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




class ServingApiTest(TestCase):
    """Tests for Serving API."""

    def setUp(self):
        self.vendor_service = VendorServiceFactory(start_date=None, end_date=None)
        self.timetable = self.vendor_service.timetable
        self.vendor = self.vendor_service.vendor
        self.date = self.timetable.ref_cycle_date

        meal = MealFactory()
        course = CourseFactory(name='main')
        dish_names = ['Quaker Oat and Moi-moi', 'Bread and Egg', 'Apples']
        self.menu_items = []
        for dish_name in dish_names:
            dish = DishFactory(name=dish_name)

            menu_item = MenuItemFactory(