Skip to content
This repository
Browse code

additional tests thanks to stephenmuss

  • Loading branch information...
commit 764f483dcb37bbe3832d706e57679df418aa8198 1 parent 2ad31cf
Ales Kocjancic authored September 14, 2012

Showing 1 changed file with 26 additions and 0 deletions. Show diff stats Hide diff stats

  1. 26  shop/tests/payment.py
26  shop/tests/payment.py
@@ -197,3 +197,29 @@ def test02_must_be_logged_in_if_setting_is_true(self):
197 197
             resp = self.client.get(reverse('pay-on-delivery'))
198 198
             self.assertEqual(resp.status_code, 302)
199 199
             self.assertTrue('accounts/login/' in resp._headers['location'][1])
  200
+
  201
+    def test_order_required_before_payment(self):
  202
+        """ See issue #84 """
  203
+        # Session only (no order)
  204
+        response = self.client.get(reverse('pay-on-delivery'))
  205
+        self.assertEqual(302, response.status_code)
  206
+        self.assertEqual('http://testserver/', response._headers['location'][1])
  207
+
  208
+        # User logged in (no order)
  209
+        username = 'user'
  210
+        pw = 'pass'
  211
+        User.objects.create_user(username=username, password=pw)
  212
+        logged_in = self.client.login(username=username, password=pw)
  213
+        self.assertTrue(logged_in)
  214
+        response = self.client.get(reverse('pay-on-delivery'))
  215
+        self.assertEqual(302, response.status_code)
  216
+        self.assertEqual('http://testserver/', response._headers['location'][1])
  217
+        self.client.logout()
  218
+
  219
+        # User logged in and has order
  220
+        self.user.set_password('blah')
  221
+        self.user.save()
  222
+        logged_in = self.client.login(username=self.user.username, password='blah')
  223
+        self.assertTrue(logged_in)
  224
+        response = self.client.get(reverse('pay-on-delivery'))
  225
+        self.assertTrue(reverse('thank_you_for_your_order') in response._headers['location'][1])

0 notes on commit 764f483

Please sign in to comment.
Something went wrong with that request. Please try again.