Example #1
0
    def test_add_to_cart_authenticated_existing_cart(self):
        """
            test an item being added to the cart via post request existing cart
        """
        user = fixtures.create_user(
            username='******', email="*****@*****.**", password='******', first_name='Test', last_name='User'
        )

        artist_user = fixtures.create_user(
            username='******', email="*****@*****.**", password='******', first_name='Test', last_name='User'
        )
        self.client.login(username=user.username, password='******')

        s = self.client.session
        s['user_id'] = user.id
        s.save()

        cart = fixtures.create_cart(session_key=s._session_key, user_id=user.id)

        art = fixtures.create_art(user_id=artist_user.id, category='test', photo='/whatever/', title='test art', description='test art')

        url = reverse('cart.views.add_to_cart', args=(art.id, ))
        resp = self.client.post(url)

        self.assertEqual(resp.status_code, 200)
Example #2
0
    def test_empty_cart(self):
        """
            test empty =cart successfully
        """

        user = fixtures.create_user(
            username='******', email="*****@*****.**", password='******', first_name='Test', last_name='User'
        )

        artist_user = fixtures.create_user(
            username='******', email="*****@*****.**", password='******', first_name='Test', last_name='User'
        )
        self.client.login(username=user.username, password='******')

        s = self.client.session
        s['user_id'] = user.id
        s.save()

        cart = fixtures.create_cart(session_key=s._session_key, user_id=user.id)

        art = fixtures.create_art(user_id=artist_user.id, category='test', photo='/whatever/', title='test art', description='test art')

        cli = fixtures.create_cart_line_item(cart_id=cart.id, art_id=art.id)

        url = reverse('cart.views.empty_cart')
        resp = self.client.post(url)

        self.assertEqual(resp.status_code, 200)
Example #3
0
    def test_cart_creation_without_user(self):
        """
            test creation of a cart model without user just sessionkey
        """

        cart = fixtures.create_cart(session_key='1234abc')


        self.assertTrue(isinstance(cart, Cart))
Example #4
0
    def test_cart_creation_with_user(self):
        """
            test creation of a cart model with a user
        """

        user = fixtures.create_user(
                username='******', password='******', email='*****@*****.**', first_name='test', last_name='user'
        )

        cart = fixtures.create_cart(user_id=user.id, session_key='1234abc')


        self.assertTrue(isinstance(cart, Cart))
Example #5
0
    def test_view_cart_authenticated_existing_cart(self):
        """
            test a get request to the view cart view for an auth user
            that has an existing cart
        """
        user = fixtures.create_user(
            username='******', email="*****@*****.**", password='******', first_name='Test', last_name='User'
        )

        self.client.login(username=user.username, password='******')

        s = self.client.session
        s['user_id'] = user.id
        s.save()

        cart = fixtures.create_cart(session_key=s._session_key, user_id=user.id)

        url = reverse('cart.views.view_cart')
        resp = self.client.get(url)

        self.assertEqual(resp.status_code, 200)
        self.assertEqual(len(Cart.objects.all()), 1)