Exemplo n.º 1
0
    def test_login(self):
        """Tests the login view.
        """
        from lfs.checkout.views import login
        from lfs.checkout.settings import CHECKOUT_TYPE_ANON

        from lfs.tests.utils import create_request
        request = create_request()

        # Anonymous
        from django.contrib.auth.models import AnonymousUser
        request.user = AnonymousUser()

        result = login(request)
        self.assertEqual(result.status_code, 200)

        # Set checkout_type
        shop = get_default_shop()
        shop.checkout_type = CHECKOUT_TYPE_ANON
        shop.save()

        # Fake a new reuqest
        request.shop = shop

        result = login(request)
        self.assertEqual(result.status_code, 302)

        # Authenticated
        request.user = self.user
        result = login(request)

        self.assertEqual(result.status_code, 302)
Exemplo n.º 2
0
    def test_login(self):
        """Tests the login view.
        """
        from lfs.checkout.views import login
        from lfs.checkout.settings import CHECKOUT_TYPE_ANON

        from lfs.tests.utils import create_request
        request = create_request()

        # Anonymous
        from django.contrib.auth.models import AnonymousUser
        request.user = AnonymousUser()

        result = login(request)
        self.assertEqual(result.status_code, 200)

        # Set checkout_type
        shop = get_default_shop()
        shop.checkout_type = CHECKOUT_TYPE_ANON
        shop.save()

        # Fake a new reuqest
        request.shop = shop

        result = login(request)
        self.assertEqual(result.status_code, 302)

        # Authenticated
        request.user = self.user
        result = login(request)

        self.assertEqual(result.status_code, 302)