# Path: tests/base.py
# class BaseFacebookAPITestCase(RestSocialMixin, FacebookOAuth2Test):
# 
#     def do_rest_login(self):
#         start_url = self.backend.start().url
#         self.auth_handlers(start_url)
# 
# class BaseTwitterApiTestCase(RestSocialMixin, TwitterOAuth1Test):
# 
#     def do_rest_login(self):
#         self.request_token_handler()
#         start_url = self.backend.start().url
#         self.auth_handlers(start_url)


from unittest import mock
from urllib.parse import parse_qsl, urlparse
from django.urls import reverse
from django.contrib.auth import get_user_model
from django.test import modify_settings
from django.test.utils import override_settings
from rest_framework.test import APITestCase
from rest_framework.permissions import DjangoModelPermissionsOrAnonReadOnly
from httpretty import HTTPretty
from social_core.utils import parse_qs
from .base import BaseFacebookAPITestCase, BaseTwitterApiTestCase




session_modify_settings = dict(
    INSTALLED_APPS={
        'remove': [
            'rest_framework.authtoken',
            'knox',
        ]
    },
)


class TestSocialAuth1(APITestCase, BaseTwitterApiTestCase):

    @modify_settings(**session_modify_settings)
    def test_login_social_oauth1_session(self):
        resp = self.client.post(
            reverse('login_social_session'), data={'provider': 'twitter'})
        self.assertEqual(resp.status_code, 200)
        self.assertEqual(resp.data, parse_qs(self.request_token_body))
        resp = self.client.post(reverse('login_social_session'), data={
            'provider': 'twitter',
            'oauth_token': 'foobar',
            'oauth_verifier': 'overifier'
        })
        self.assertEqual(resp.status_code, 200)



# Path: tests/base.py
# class BaseFacebookAPITestCase(RestSocialMixin, FacebookOAuth2Test):
# 
#     def do_rest_login(self):
#         start_url = self.backend.start().url
#         self.auth_handlers(start_url)
# 
# class BaseTwitterApiTestCase(RestSocialMixin, TwitterOAuth1Test):
# 
#     def do_rest_login(self):
#         self.request_token_handler()
#         start_url = self.backend.start().url
#         self.auth_handlers(start_url)


# Path: tests/test_session.py
from unittest import mock
from urllib.parse import parse_qsl, urlparse
from django.urls import reverse
from django.contrib.auth import get_user_model
from django.test import modify_settings
from django.test.utils import override_settings
from rest_framework.test import APITestCase
from rest_framework.permissions import DjangoModelPermissionsOrAnonReadOnly
from httpretty import HTTPretty
from social_core.utils import parse_qs
from .base import BaseFacebookAPITestCase, BaseTwitterApiTestCase





session_modify_settings = dict(
    INSTALLED_APPS={
        'remove': [
            'rest_framework.authtoken',
            'knox',
        ]
    },
)


class TestSocialAuth1(APITestCase, BaseTwitterApiTestCase):

    @modify_settings(**session_modify_settings)
    def test_login_social_oauth1_session(self):
        resp = self.client.post(
            reverse('login_social_session'), data={'provider': 'twitter'})
        self.assertEqual(resp.status_code, 200)
        self.assertEqual(resp.data, parse_qs(self.request_token_body))
        resp = self.client.post(reverse('login_social_session'), data={
            'provider': 'twitter',
            'oauth_token': 'foobar',
            'oauth_verifier': 'overifier'
        })
        self.assertEqual(resp.status_code, 200)



class TestSocialAuth2(APITestCase, BaseFacebookAPITestCase):