Permalink
Browse files

additional tests thanks to stephenmuss

  • Loading branch information...
1 parent 2ad31cf commit 764f483dcb37bbe3832d706e57679df418aa8198 Ales Kocjancic committed Sep 14, 2012
Showing with 26 additions and 0 deletions.
  1. +26 −0 shop/tests/payment.py
View
@@ -197,3 +197,29 @@ def test02_must_be_logged_in_if_setting_is_true(self):
resp = self.client.get(reverse('pay-on-delivery'))
self.assertEqual(resp.status_code, 302)
self.assertTrue('accounts/login/' in resp._headers['location'][1])
+
+ def test_order_required_before_payment(self):
+ """ See issue #84 """
+ # Session only (no order)
+ response = self.client.get(reverse('pay-on-delivery'))
+ self.assertEqual(302, response.status_code)
+ self.assertEqual('http://testserver/', response._headers['location'][1])
+
+ # User logged in (no order)
+ username = 'user'
+ pw = 'pass'
+ User.objects.create_user(username=username, password=pw)
+ logged_in = self.client.login(username=username, password=pw)
+ self.assertTrue(logged_in)
+ response = self.client.get(reverse('pay-on-delivery'))
+ self.assertEqual(302, response.status_code)
+ self.assertEqual('http://testserver/', response._headers['location'][1])
+ self.client.logout()
+
+ # User logged in and has order
+ self.user.set_password('blah')
+ self.user.save()
+ logged_in = self.client.login(username=self.user.username, password='blah')
+ self.assertTrue(logged_in)
+ response = self.client.get(reverse('pay-on-delivery'))
+ self.assertTrue(reverse('thank_you_for_your_order') in response._headers['location'][1])

0 comments on commit 764f483

Please sign in to comment.