# Path: tests/tests/test_cases.py
# class ApprovalTestCase(OAuthTestCase):
# 
#     def setUp(self):
#         super(ApprovalTestCase, self).setUp()
# 
#         self.redirect_uri = RedirectUri(client=self.oauth_client, url="http://localhost/redirect_endpoint/")
#         self.redirect_uri.save()
# 
#         self.authorization_code = AuthorizationCode(client=self.oauth_client, redirect_uri=self.redirect_uri)
#         self.authorization_code.save()
# 
#         self.authorization_code.scope = [self.scope]
#         self.authorization_code.save()


from django.core.urlresolvers import reverse
from ..test_cases import ApprovalTestCase
        from doac.exceptions.invalid_request import AuthorizationCodeNotValid, AuthorizationCodeNotProvided
        from doac.exceptions.access_denied import AuthorizationDenied
        from doac.models import AuthorizationToken
        from doac.models import AccessToken
        import urllib
        import urllib
    
    def test_code(self):
        
        request = self.client.post(reverse("oauth2_approval"))
        self.assertExceptionRendered(request, AuthorizationCodeNotProvided())
        
        request = self.client.post(reverse("oauth2_approval") + "?code=invalid")
        self.assertExceptionRendered(request, AuthorizationCodeNotProvided())
        
        request = self.client.post(reverse("oauth2_approval"), {"code": "invalid"})
        self.assertExceptionRendered(request, AuthorizationCodeNotValid())
        
        data = {
            "code": "invalid",
        }
        
        request = self.client.post(reverse("oauth2_approval") + "?code=%s" % (self.authorization_code.token, ), data)
        self.assertExceptionRendered(request, AuthorizationCodeNotValid())
        
        data = {
            "code": self.authorization_code.token,
        }
        
        request = self.client.post(reverse("oauth2_approval") + "?code=invalid", data)
        self.assertExceptionRendered(request, AuthorizationCodeNotValid())
        
        request = self.client.post(reverse("oauth2_approval") + "?code=invalid", {"code": "invalid"})
        self.assertExceptionRendered(request, AuthorizationCodeNotValid())



# Path: tests/tests/test_cases.py
# class ApprovalTestCase(OAuthTestCase):
# 
#     def setUp(self):
#         super(ApprovalTestCase, self).setUp()
# 
#         self.redirect_uri = RedirectUri(client=self.oauth_client, url="http://localhost/redirect_endpoint/")
#         self.redirect_uri.save()
# 
#         self.authorization_code = AuthorizationCode(client=self.oauth_client, redirect_uri=self.redirect_uri)
#         self.authorization_code.save()
# 
#         self.authorization_code.scope = [self.scope]
#         self.authorization_code.save()


# Path: tests/tests/views/test_approval.py
from django.core.urlresolvers import reverse
from ..test_cases import ApprovalTestCase
        from doac.exceptions.invalid_request import AuthorizationCodeNotValid, AuthorizationCodeNotProvided
        from doac.exceptions.access_denied import AuthorizationDenied
        from doac.models import AuthorizationToken
        from doac.models import AccessToken
        import urllib
        import urllib

    
    def test_code(self):
        
        request = self.client.post(reverse("oauth2_approval"))
        self.assertExceptionRendered(request, AuthorizationCodeNotProvided())
        
        request = self.client.post(reverse("oauth2_approval") + "?code=invalid")
        self.assertExceptionRendered(request, AuthorizationCodeNotProvided())
        
        request = self.client.post(reverse("oauth2_approval"), {"code": "invalid"})
        self.assertExceptionRendered(request, AuthorizationCodeNotValid())
        
        data = {
            "code": "invalid",
        }
        
        request = self.client.post(reverse("oauth2_approval") + "?code=%s" % (self.authorization_code.token, ), data)
        self.assertExceptionRendered(request, AuthorizationCodeNotValid())
        
        data = {
            "code": self.authorization_code.token,
        }
        
        request = self.client.post(reverse("oauth2_approval") + "?code=invalid", data)
        self.assertExceptionRendered(request, AuthorizationCodeNotValid())
        
        request = self.client.post(reverse("oauth2_approval") + "?code=invalid", {"code": "invalid"})
        self.assertExceptionRendered(request, AuthorizationCodeNotValid())



class TestApprovalResponse(ApprovalTestCase):