# Path: tests/factories.py
# class UserFactory(factory.django.DjangoModelFactory):
#     class Meta:
# 
# Path: tests/queries.py
# ALL_USERS = """query {
#   allUsers {
#     results {
#       id
#     }
#   }
# }
# """
# ALL_USERS1 = """query {
#   allUsers1 {
#       id
#       username
#       firstName
#       lastName
#       email
#   }
# }
# """
# ALL_USERS2 = """query {
#   allUsers2 {
#       username
#   }
# }
# """
# ALL_USERS3 = """query {
#   allUsers3 {
#       id
#   }
# }
# """
# ALL_USERS4 = """query {
#   allUsers4 {
#     id
#     username
#   }
# }
# """
# ALL_USERS3_WITH_FILTER = """query {
#   allUsers3 (%(filter)s) {
#     results {
#       %(fields)s
#     }
#   }
# }
# """
# USER = """query {
#   user2 (%(filter)s) {
#       %(fields)s
#   }
# }
# """
# USERS = """query {
#   users(%(filter)s){
#     results(%(pagination)s){
#         %(fields)s
#     },
#     totalCount
#   }
# }
# """
# 
# Path: tests/client.py
# class Client(BaseClient):
#     url = reverse("graphql")
# 
#     def query(self, query):
#         response = self.get(path=self.url, data={"query": query})
#         return response


import uuid
from django.test import TestCase
from tests import factories
from tests import queries
from tests.client import Client


class DjangoListObjectFieldTest(ParentTest, TestCase):
    query = queries.ALL_USERS
    expected_return_payload = {"data": {"allUsers": {"results": [{"id": "1"}]}}}

    def test_field(self):
        self.assertEqual(
            self.data["data"]["allUsers"]["results"][0]["id"], str(self.user.id)
        )


class DjangoFilterPaginateListFieldTest(ParentTest, TestCase):
    query = queries.ALL_USERS1
    expected_return_payload = {
        "data": {
            "allUsers1": [
                {
                    "id": "1",
                    "username": "graphql",
                    "firstName": "Ernesto",
                    "lastName": "Perez Amigo",
                    "email": "eamigop86@gmail.com",
                }
            ]
        }
    }


class DjangoFilterListFieldTest(ParentTest, TestCase):

# Path: tests/factories.py
# class UserFactory(factory.django.DjangoModelFactory):
#     class Meta:
# 
# Path: tests/queries.py
# ALL_USERS = """query {
#   allUsers {
#     results {
#       id
#     }
#   }
# }
# """
# ALL_USERS1 = """query {
#   allUsers1 {
#       id
#       username
#       firstName
#       lastName
#       email
#   }
# }
# """
# ALL_USERS2 = """query {
#   allUsers2 {
#       username
#   }
# }
# """
# ALL_USERS3 = """query {
#   allUsers3 {
#       id
#   }
# }
# """
# ALL_USERS4 = """query {
#   allUsers4 {
#     id
#     username
#   }
# }
# """
# ALL_USERS3_WITH_FILTER = """query {
#   allUsers3 (%(filter)s) {
#     results {
#       %(fields)s
#     }
#   }
# }
# """
# USER = """query {
#   user2 (%(filter)s) {
#       %(fields)s
#   }
# }
# """
# USERS = """query {
#   users(%(filter)s){
#     results(%(pagination)s){
#         %(fields)s
#     },
#     totalCount
#   }
# }
# """
# 
# Path: tests/client.py
# class Client(BaseClient):
#     url = reverse("graphql")
# 
#     def query(self, query):
#         response = self.get(path=self.url, data={"query": query})
#         return response


# Path: tests/test_fields.py
import uuid
from django.test import TestCase
from tests import factories
from tests import queries
from tests.client import Client



class DjangoListObjectFieldTest(ParentTest, TestCase):
    query = queries.ALL_USERS
    expected_return_payload = {"data": {"allUsers": {"results": [{"id": "1"}]}}}

    def test_field(self):
        self.assertEqual(
            self.data["data"]["allUsers"]["results"][0]["id"], str(self.user.id)
        )


class DjangoFilterPaginateListFieldTest(ParentTest, TestCase):
    query = queries.ALL_USERS1
    expected_return_payload = {
        "data": {
            "allUsers1": [
                {
                    "id": "1",
                    "username": "graphql",
                    "firstName": "Ernesto",
                    "lastName": "Perez Amigo",
                    "email": "eamigop86@gmail.com",
                }
            ]
        }
    }


class DjangoFilterListFieldTest(ParentTest, TestCase):

    query = queries.ALL_USERS2