コード例 #1
0
 def test_post_request(self):
     """Only POST requests should be allowed."""
     get_request = self.request_factory.get(self.url)
     response = stripe_webhook(get_request)
     eq_(response.status_code, 405,
         'Should respond to GET request with 405')
     post_request = self.request_factory.post(
         self.url, data=self.data, content_type='application/json')
     response = stripe_webhook(post_request)
     eq_(response.status_code, 200,
         'Should respond to POST request with 200')
コード例 #2
0
 def test_missing_data(self):
     """POSTing unexpected JSON should return a 400 status code."""
     bad_data = json.dumps({'hello': 'world'})
     post_request = self.request_factory.post(
         self.url, data=bad_data, content_type='application/json')
     response = stripe_webhook(post_request)
     eq_(response.status_code, 400)
コード例 #3
0
ファイル: test_webhooks.py プロジェクト: clytwynec/muckrock
 def test_bad_json(self):
     """POSTing bad JSON should return a 400 status code."""
     post_request = self.request_factory.post(
         self.url, data=u'Not JSON', content_type='application/json'
     )
     response = stripe_webhook(post_request)
     eq_(response.status_code, 400)
コード例 #4
0
 def test_invoice_failed(self, mock_task):
     """When an invoice payment failed event is received, send a notification."""
     self.mock_event['type'] = 'invoice.payment_failed'
     post_request = self.request_factory.post(
         self.url,
         data=json.dumps(self.mock_event),
         content_type='application/json')
     response = stripe_webhook(post_request)
     eq_(response.status_code, 200)
     mock_task.called_once()
コード例 #5
0
 def test_charge_succeeded(self, mock_task):
     """When a charge succeeded event is received, send a charge receipt."""
     self.mock_event['type'] = 'charge.succeeded'
     post_request = self.request_factory.post(
         self.url,
         data=json.dumps(self.mock_event),
         content_type='application/json')
     response = stripe_webhook(post_request)
     eq_(response.status_code, 200)
     mock_task.called_once()