Skip to content

Commit

Permalink
Add a couple more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jleclanche committed Jun 11, 2020
1 parent c7c2db2 commit 1479fc9
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/test_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ def test_get_default_account(self, fileupload_retrieve_mock, account_retrieve_mo

self.assert_fks(account, expected_blank_fks={})

self.assertEqual(account.business_url, "https://example.com")
account.business_profile = None
self.assertEqual(account.business_url, None)

@patch("stripe.Account.retrieve", autospec=IS_STATICMETHOD_AUTOSPEC_SUPPORTED)
@patch(
"stripe.FileUpload.retrieve",
Expand Down
2 changes: 2 additions & 0 deletions tests/test_charge.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ def test_capture_charge(
captured_charge = charge.capture()
self.assertTrue(captured_charge.captured)

self.assertFalse(captured_charge.fraudulent)

self.assert_fks(
charge,
expected_blank_fks=self.default_expected_blank_fks
Expand Down
8 changes: 8 additions & 0 deletions tests/test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ def setUp(self):
def test_view(request):
return HttpResponse()

@subscription_payment_required(pay_page=None)
def test_view_bad(request):
return HttpResponse()

self.test_view = test_view
self.test_view_bad = test_view_bad

def test_direct(self):
subscription_payment_required(function=None)
Expand All @@ -50,6 +55,9 @@ def test_user_unpaid(self):
response = self.test_view(request)
self.assertEqual(response.status_code, 302)

with self.assertRaises(ImproperlyConfigured):
self.test_view_bad(request)

@patch("stripe.Plan.retrieve", return_value=deepcopy(FAKE_PLAN), autospec=True)
@patch(
"stripe.Product.retrieve", return_value=deepcopy(FAKE_PRODUCT), autospec=True
Expand Down
3 changes: 3 additions & 0 deletions tests/test_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,9 @@ def test_upcoming_invoice(
self.assertIsNone(invoice.save())
self.assertEqual(invoice.get_stripe_dashboard_url(), "")

invoice.id = "foo"
self.assertIsNone(invoice.id)

subscription_retrieve_mock.assert_called_once_with(
api_key=ANY, expand=ANY, id=FAKE_SUBSCRIPTION["id"], stripe_account=None
)
Expand Down
4 changes: 4 additions & 0 deletions tests/test_webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,10 @@ def test_event_handle_registation_with_list_of_strings(self):
self.assertEqual(2, func_mock.call_count)
func_mock.assert_has_calls([call(event=event1), call(event=event2)])

def test_webhook_event_trigger_invalid_body(self):
trigger = WebhookEventTrigger(remote_ip="127.0.0.1", body="invalid json")
assert not trigger.json_body

#
# Helpers
#
Expand Down

0 comments on commit 1479fc9

Please sign in to comment.