from django.urls import reverse
from django.contrib.auth.models import User
from rest_framework import status
from billjobs.tests.generics import GenericAPITest, GenericAPIStatusCode

class AnonymousGroupAPITest(GenericAPITest):
    """
    Tests status code and response content returned by /groups endpoint for
    anonymous user.
    """

    def setUp(self):
        super().setUp()
        self.url = reverse('groups-api')
        self.data = {
                'create': {'name': 'group name'},
                'update': {'name': 'new name'}
                }
        self.expected_status = {
                'GET': 401,
                'POST': 401,
                'PUT': 401,
                'DELETE': 401,
                'HEAD': 401,
                'OPTIONS': 401,
                'PATCH': 401,
                }
        self.expected_content = {
                'GET': {
                    'detail': 'Authentication credentials were not provided.'},
                'POST': {
                    'detail': 'Authentication credentials were not provided.'},
                'PUT': {
                    'detail': 'Authentication credentials were not provided.'},
                'DELETE': {
                    'detail': 'Authentication credentials were not provided.'},
                'HEAD': {
                    'detail': 'Authentication credentials were not provided.'},
                'OPTIONS': {
                    'detail': 'Authentication credentials were not provided.'},
                'PATCH': {
                    'detail': 'Authentication credentials were not provided.'},
                }

    def tearDown(self):
        super().tearDown()

    def test_group_api_status_code(self):
        self.status_code_is()

    def test_group_api_content(self):
        self.content_is()

class AnonymousGroupDetailAPITest(GenericAPITest):
    """
    Tests status code and response content returned by /groups/pk endpoint for
    anonymous user.
    """

    def setUp(self):
        super().setUp()
        self.url = reverse('groups-detail-api', args=(1,))
        self.data = {
                'create': {'name': 'group name'},
                'update': {'name': 'new name'}
                }
        self.expected_status = {
                'GET': 401,
                'POST': 401,
                'PUT': 401,
                'DELETE': 401,
                'HEAD': 401,
                'OPTIONS': 401,
                'PATCH': 401,
                }
        self.expected_content = {
                'GET': {
                    'detail': 'Authentication credentials were not provided.'},
                'POST': {
                    'detail': 'Authentication credentials were not provided.'},
                'PUT': {
                    'detail': 'Authentication credentials were not provided.'},
                'DELETE': {
                    'detail': 'Authentication credentials were not provided.'},
                'HEAD': {
                    'detail': 'Authentication credentials were not provided.'},
                'OPTIONS': {
                    'detail': 'Authentication credentials were not provided.'},
                'PATCH': {
                    'detail': 'Authentication credentials were not provided.'},
                }

    def tearDown(self):
        super().tearDown()

    def test_group_api_status_code(self):
        self.status_code_is()

    def test_group_api_content(self):
        self.content_is()


@@ -3440,28 +3440,1717 @@
 %0A        self.content_is()%0A%0A
+class UserGroupAPITest(GenericAPITest):%0A    %22%22%22%0A    Tests status code and response content returned by /groups endpoint for%0A    authenticated user.%0A    %22%22%22%0A%0A    def setUp(self):%0A        super().setUp()%0A        self.url = reverse('groups-api')%0A        self.force_authenticate(user=self.user)%0A        self.data = %7B%0A                'create': %7B'name': 'group name'%7D,%0A                'update': %7B'name': 'new name'%7D%0A                %7D%0A        self.expected_status = %7B%0A                'GET': 200,%0A                'POST': 403,%0A                'PUT': 403,%0A                'DELETE': 403,%0A                'HEAD': 403,%0A                'OPTIONS': 403,%0A                'PATCH': 403,%0A                %7D%0A        self.expected_content = %7B%0A                'GET': %7B%0A                    'detail': 'Authentication credentials were not provided.'%7D,%0A                'POST': %7B%0A                    'detail': 'Authentication credentials were not provided.'%7D,%0A                'PUT': %7B%0A                    'detail': 'Authentication credentials were not provided.'%7D,%0A                'DELETE': %7B%0A                    'detail': 'Authentication credentials were not provided.'%7D,%0A                'HEAD': %7B%0A                    'detail': 'Authentication credentials were not provided.'%7D,%0A                'OPTIONS': %7B%0A                    'detail': 'Authentication credentials were not provided.'%7D,%0A                'PATCH': %7B%0A                    'detail': 'Authentication credentials were not provided.'%7D,%0A                %7D%0A%0A    def tearDown(self):%0A        super().tearDown()%0A%0A    def test_group_api_status_code(self):%0A        self.status_code_is()%0A%0A    def test_group_api_content(self):%0A        pass%0A        #self.content_is()%0A%0A

test response status code returned to an authenticated user with all HTTP method for /groups endpoint