# 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/timetables/factories.py
# class EventFactory(TimestampFactory):
#     """Event model factory."""
# 
#     class Meta:
#         model = models.Event
# 
#     name = 'Christmas'
#     timetable = factory.SubFactory(TimetableFactory)
#     action = 'no-meal'
#     start_date = timezone.make_aware(timezone.datetime(2008, 12, 23, 0, 0, 0))
#     end_date = timezone.make_aware(timezone.datetime(2008, 12, 28, 0, 0, 0))


from django.test import Client, TestCase
from .utils import create_admin_account, make_request
from app.timetables.factories import EventFactory



class EventApiTest(TestCase):

    def setUp(self):
        self.client = Client()
        create_admin_account()
        self.event = EventFactory()

    def retrieve_event(self):
        query = 'query {events{edges{node{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/timetables/factories.py
# class EventFactory(TimestampFactory):
#     """Event model factory."""
# 
#     class Meta:
#         model = models.Event
# 
#     name = 'Christmas'
#     timetable = factory.SubFactory(TimetableFactory)
#     action = 'no-meal'
#     start_date = timezone.make_aware(timezone.datetime(2008, 12, 23, 0, 0, 0))
#     end_date = timezone.make_aware(timezone.datetime(2008, 12, 28, 0, 0, 0))


# Path: app/api/tests/test_event_crud.py
from django.test import Client, TestCase
from .utils import create_admin_account, make_request
from app.timetables.factories import EventFactory




class EventApiTest(TestCase):

    def setUp(self):
        self.client = Client()
        create_admin_account()
        self.event = EventFactory()

    def retrieve_event(self):
        query = 'query {events{edges{node{name}}}}'

        return make_request(self.client, query)