Beispiel #1
0
 def test_normal_post_error(self, sms_mock):
     """Should not send sms and should return the form with error message."""
     req = self.rf.post('/', {'number': '8675309'})
     resp = views.sms_send(req)
     self.assertEqual(resp.status_code, 200)
     self.assertContains(resp, u'Sorry. This number isn\'t valid.')
     self.assertFalse(sms_mock.called)
Beispiel #2
0
 def test_normal_post_error(self, sms_mock):
     """Should not send sms and should return the form with error message."""
     req = self.rf.post('/', {'number': '8675309'})
     resp = views.sms_send(req)
     self.assertEqual(resp.status_code, 200)
     self.assertContains(resp, u'Sorry. This number isn\'t valid.')
     self.assertFalse(sms_mock.called)
Beispiel #3
0
 def test_normal_basket_error(self, sms_mock):
     """Should not send sms and should return the form with error message."""
     sms_mock.side_effect = views.basket.BasketException
     req = self.rf.post('/', {'number': '5558675309'})
     resp = views.sms_send(req)
     sms_mock.assert_called_with('15558675309', 'SMS_Android', False)
     self.assertEqual(resp.status_code, 200)
     self.assertContains(resp, u'An error occurred in our system. Please try again later.')
Beispiel #4
0
 def test_ajax_post_success(self, sms_mock):
     """Should send sms and return a JSON response."""
     req = self.rf.post('/', {'number': '5558675309'},
                        HTTP_X_REQUESTED_WITH='XMLHttpRequest')
     resp = views.sms_send(req)
     sms_mock.assert_called_with('15558675309', 'SMS_Android', False)
     self.assertEqual(resp.status_code, 200)
     resp_data = json.loads(resp.content)
     self.assertEqual(resp_data, {'success': True})
Beispiel #5
0
 def test_normal_basket_error(self, sms_mock):
     """Should not send sms and should return the form with error message."""
     sms_mock.side_effect = views.basket.BasketException
     req = self.rf.post('/', {'number': '5558675309'})
     resp = views.sms_send(req)
     sms_mock.assert_called_with('15558675309', 'SMS_Android', False)
     self.assertEqual(resp.status_code, 200)
     self.assertContains(
         resp, u'An error occurred in our system. Please try again later.')
Beispiel #6
0
 def test_ajax_post_success(self, sms_mock):
     """Should send sms and return a JSON response."""
     req = self.rf.post('/', {'number': '5558675309'},
                        HTTP_X_REQUESTED_WITH='XMLHttpRequest')
     resp = views.sms_send(req)
     sms_mock.assert_called_with('15558675309', 'SMS_Android', False)
     self.assertEqual(resp.status_code, 200)
     resp_data = json.loads(resp.content)
     self.assertEqual(resp_data, {'success': True})
Beispiel #7
0
 def test_ajax_post_error(self, sms_mock):
     """Should not send sms and should return a JSON response."""
     req = self.rf.post('/', {'number': '8675309'},
                        HTTP_X_REQUESTED_WITH='XMLHttpRequest')
     resp = views.sms_send(req)
     self.assertFalse(sms_mock.called)
     self.assertEqual(resp.status_code, 200)
     resp_data = json.loads(resp.content)
     self.assertFalse(resp_data['success'])
     self.assertIn(u'Sorry. This number isn\'t valid.', resp_data['error'])
Beispiel #8
0
 def test_ajax_post_error(self, sms_mock):
     """Should not send sms and should return a JSON response."""
     req = self.rf.post('/', {'number': '8675309'},
                        HTTP_X_REQUESTED_WITH='XMLHttpRequest')
     resp = views.sms_send(req)
     self.assertFalse(sms_mock.called)
     self.assertEqual(resp.status_code, 200)
     resp_data = json.loads(resp.content)
     self.assertFalse(resp_data['success'])
     self.assertIn(u'Sorry. This number isn\'t valid.', resp_data['error'])
Beispiel #9
0
 def test_ajax_basket_error(self, sms_mock):
     """Should not send sms and should return a JSON response."""
     sms_mock.side_effect = views.basket.BasketException
     req = self.rf.post('/', {'number': '5558675309'},
                        HTTP_X_REQUESTED_WITH='XMLHttpRequest')
     resp = views.sms_send(req)
     sms_mock.assert_called_with('15558675309', 'SMS_Android', False)
     self.assertEqual(resp.status_code, 200)
     resp_data = json.loads(resp.content)
     self.assertEqual(resp_data, {
         'success': False,
         'error': u'An error occurred in our system. Please try again later.',
     })
Beispiel #10
0
 def test_ajax_basket_error(self, sms_mock):
     """Should not send sms and should return a JSON response."""
     sms_mock.side_effect = views.basket.BasketException
     req = self.rf.post('/', {'number': '5558675309'},
                        HTTP_X_REQUESTED_WITH='XMLHttpRequest')
     resp = views.sms_send(req)
     sms_mock.assert_called_with('15558675309', 'SMS_Android', False)
     self.assertEqual(resp.status_code, 200)
     resp_data = json.loads(resp.content)
     self.assertEqual(
         resp_data, {
             'success':
             False,
             'error':
             u'An error occurred in our system. Please try again later.',
         })
Beispiel #11
0
 def test_normal_post_success(self, sms_mock):
     """Should send sms and return a redirect."""
     req = self.rf.post('/', {'number': '5558675309'})
     resp = views.sms_send(req)
     sms_mock.assert_called_with('15558675309', 'SMS_Android', False)
     self.assertEqual(resp.status_code, 302)
Beispiel #12
0
 def test_normal_post_success(self, sms_mock):
     """Should send sms and return a redirect."""
     req = self.rf.post('/', {'number': '5558675309'})
     resp = views.sms_send(req)
     sms_mock.assert_called_with('15558675309', 'SMS_Android', False)
     self.assertEqual(resp.status_code, 302)