# Path: app/api/tests/utils.py
# def obtain_api_key(client):
# def create_admin_account():
# def create_normal_user_acount():
# def make_request(client, query, method='GET'):


from django.test import Client, TestCase
from .utils import (admin_test_credentials, create_admin_account,
                    make_request,)

    def create_user(self, username, password):
        query = '''
            mutation{
              createUser(input: {user:{username: "%s", password: "%s"}}){
                user{
                  id,
                  originalId,
                  username
                }
              }
            }
        ''' % (username, password)

        return make_request(self.client, query, 'POST')

    def create_multiple_users(self):
        new_users = (
            ('john', 'qwerty123'),
            ('raphael', 'qwerty123'),
            ('samson', 'qwerty123'),
        )

        [self.create_user(username, password) for username, password in new_users]

        return new_users

    def retrieve_user(self, user_id):
        query = 'query {user(id: "%s") {username}}' % (user_id)


# Path: app/api/tests/utils.py
# def obtain_api_key(client):
# def create_admin_account():
# def create_normal_user_acount():
# def make_request(client, query, method='GET'):


# Path: app/api/tests/test_user_api.py
from django.test import Client, TestCase
from .utils import (admin_test_credentials, create_admin_account,
                    make_request,)


    def create_user(self, username, password):
        query = '''
            mutation{
              createUser(input: {user:{username: "%s", password: "%s"}}){
                user{
                  id,
                  originalId,
                  username
                }
              }
            }
        ''' % (username, password)

        return make_request(self.client, query, 'POST')

    def create_multiple_users(self):
        new_users = (
            ('john', 'qwerty123'),
            ('raphael', 'qwerty123'),
            ('samson', 'qwerty123'),
        )

        [self.create_user(username, password) for username, password in new_users]

        return new_users

    def retrieve_user(self, user_id):
        query = 'query {user(id: "%s") {username}}' % (user_id)


        return make_request(self.client, query)