# Path: app/timetables/factories.py
# class ServingFactory(TimestampFactory):
#     """Serving model factory."""
# 
#     class Meta:
#         model = models.Serving
# 
#     menu_item = factory.SubFactory(MenuItemFactory)
#     vendor = factory.SubFactory(VendorFactory)
#     date_served = datetime.date(2016, 10, 1)
# 
# 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 ServingFactory
from .utils import create_admin_account, make_request
                mutation{
                    createReview(input: {serving: "%s", value: "%s", comment: "%s"}){
                        review{
                            id,
                            originalId,
                            value,
                            comment,
                            serving{
                                publicId
                            }
                        }
                    }
                }
                ''' % (serving_public_id, value, comment)
        return make_request(self.client, query, 'POST')

    def retrieve_review(self, review_id):
        query = '''query {
                    review(id: "%s") {
                        id,
                        originalId,
                        value,
                        comment,
                        serving{
                            publicId
                        }
                    }
                }
                ''' % (review_id)


# Path: app/timetables/factories.py
# class ServingFactory(TimestampFactory):
#     """Serving model factory."""
# 
#     class Meta:
#         model = models.Serving
# 
#     menu_item = factory.SubFactory(MenuItemFactory)
#     vendor = factory.SubFactory(VendorFactory)
#     date_served = datetime.date(2016, 10, 1)
# 
# 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_review_api.py
from django.test import Client, TestCase
from app.timetables.factories import ServingFactory
from .utils import create_admin_account, make_request

                mutation{
                    createReview(input: {serving: "%s", value: "%s", comment: "%s"}){
                        review{
                            id,
                            originalId,
                            value,
                            comment,
                            serving{
                                publicId
                            }
                        }
                    }
                }
                ''' % (serving_public_id, value, comment)
        return make_request(self.client, query, 'POST')

    def retrieve_review(self, review_id):
        query = '''query {
                    review(id: "%s") {
                        id,
                        originalId,
                        value,
                        comment,
                        serving{
                            publicId
                        }
                    }
                }
                ''' % (review_id)


        return make_request(self.client, query)