# Path: incuna_test_utils/testcases/api_request.py
# class BaseAPIExampleTestCase(APIExampleMixin, BaseAPIRequestTestCase):
#     SERVER_NAME = 'localhost:8000'
# 
#     def create_request(self, *args, **kwargs):
#         """Set the server domain name on the new request."""
#         return super(BaseAPIExampleTestCase, self).create_request(
#             *args, SERVER_NAME=self.SERVER_NAME, **kwargs)
# 
# class BaseAPIRequestTestCase(BaseRequestTestCase):
#     """
#     Extend BaseRequestTestCase with REST framework compatibility.
# 
#     Must be subclassed with an user_factory attribute in order to work.
#     """
#     request_factory = APIRequestFactory
# 
#     def create_request(self, method='get', url='/', user=None, auth=True, **kwargs):
#         kwargs['format'] = 'json'
#         request = super(BaseAPIRequestTestCase, self).create_request(
#             method=method,
#             url=url,
#             user=user,
#             auth=auth,
#             **kwargs)
#         if auth:
#             force_authenticate(request, request.user)
#         return request
# 
# Path: tests/factories.py
# class UserFactory(BaseUserFactory):
#     username = factory.Sequence('User {}'.format)
# 
#     class Meta:
#         model = User


from django.test import override_settings
from incuna_test_utils.testcases.api_request import (
    BaseAPIExampleTestCase, BaseAPIRequestTestCase,
)
from tests.factories import UserFactory



class APIRequestTestCase(BaseAPIRequestTestCase):
    user_factory = UserFactory

    def test_create_request_format(self):
        request = self.create_request()
        assert request.META['format'] == 'json'

    def test_create_request_auth(self):
        request = self.create_request()

# Path: incuna_test_utils/testcases/api_request.py
# class BaseAPIExampleTestCase(APIExampleMixin, BaseAPIRequestTestCase):
#     SERVER_NAME = 'localhost:8000'
# 
#     def create_request(self, *args, **kwargs):
#         """Set the server domain name on the new request."""
#         return super(BaseAPIExampleTestCase, self).create_request(
#             *args, SERVER_NAME=self.SERVER_NAME, **kwargs)
# 
# class BaseAPIRequestTestCase(BaseRequestTestCase):
#     """
#     Extend BaseRequestTestCase with REST framework compatibility.
# 
#     Must be subclassed with an user_factory attribute in order to work.
#     """
#     request_factory = APIRequestFactory
# 
#     def create_request(self, method='get', url='/', user=None, auth=True, **kwargs):
#         kwargs['format'] = 'json'
#         request = super(BaseAPIRequestTestCase, self).create_request(
#             method=method,
#             url=url,
#             user=user,
#             auth=auth,
#             **kwargs)
#         if auth:
#             force_authenticate(request, request.user)
#         return request
# 
# Path: tests/factories.py
# class UserFactory(BaseUserFactory):
#     username = factory.Sequence('User {}'.format)
# 
#     class Meta:
#         model = User


# Path: tests/testcases/test_api_request.py
from django.test import override_settings
from incuna_test_utils.testcases.api_request import (
    BaseAPIExampleTestCase, BaseAPIRequestTestCase,
)
from tests.factories import UserFactory




class APIRequestTestCase(BaseAPIRequestTestCase):
    user_factory = UserFactory

    def test_create_request_format(self):
        request = self.create_request()
        assert request.META['format'] == 'json'

    def test_create_request_auth(self):
        request = self.create_request()

        assert request.user.is_authenticated