# Path: auth/middleware.py
# class AuthMiddleware(object):
#     def process_request(self, request):
#         token = request.GET.get("TSURU_TOKEN")
# 
#         if hasattr(request, 'session') and not token:
#             token = request.session.get('tsuru_token')
# 
#         if not token:
#             return HttpResponse(status=401)
# 
#         request.token = token


from django.test import TestCase
from django.test.client import RequestFactory
from auth.middleware import AuthMiddleware



class TestVerifyTokenMiddleware(TestCase):
    def test_process_request_without_token(self):
        middleware = AuthMiddleware()

        request_mock = RequestFactory().get("/")
        result = middleware.process_request(request_mock)
        self.assertEqual(result.status_code, 401)

    def test_process_request(self):

# Path: auth/middleware.py
# class AuthMiddleware(object):
#     def process_request(self, request):
#         token = request.GET.get("TSURU_TOKEN")
# 
#         if hasattr(request, 'session') and not token:
#             token = request.session.get('tsuru_token')
# 
#         if not token:
#             return HttpResponse(status=401)
# 
#         request.token = token


# Path: auth/tests.py
from django.test import TestCase
from django.test.client import RequestFactory
from auth.middleware import AuthMiddleware




class TestVerifyTokenMiddleware(TestCase):
    def test_process_request_without_token(self):
        middleware = AuthMiddleware()

        request_mock = RequestFactory().get("/")
        result = middleware.process_request(request_mock)
        self.assertEqual(result.status_code, 401)

    def test_process_request(self):

        middleware = AuthMiddleware()