Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit aff49b3

Browse files
committed
add test
1 parent 4330f01 commit aff49b3

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

services/tests/test_billing.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,6 +1696,32 @@ def test_create_checkout_session_with_stripe_customer_id(
16961696
customer_update={"name": "auto", "address": "auto"},
16971697
)
16981698

1699+
@patch("logging.Logger.error")
1700+
@patch("services.billing.stripe.checkout.Session.create")
1701+
def test_create_checkout_session_with_invalid_plan(
1702+
self, create_checkout_session_mock, logger_error_mock
1703+
):
1704+
stripe_customer_id = "test-cusa78723hb4@"
1705+
owner = OwnerFactory(
1706+
service=Service.GITHUB.value,
1707+
stripe_customer_id=stripe_customer_id,
1708+
)
1709+
desired_quantity = 25
1710+
desired_plan = {
1711+
"value": "invalid_plan",
1712+
"quantity": desired_quantity,
1713+
}
1714+
1715+
self.stripe.create_checkout_session(owner, desired_plan)
1716+
1717+
create_checkout_session_mock.assert_not_called()
1718+
logger_error_mock.assert_called_once_with(
1719+
f"Plan {desired_plan['value']} not found",
1720+
extra=dict(
1721+
owner_id=owner.ownerid,
1722+
),
1723+
)
1724+
16991725
def test_get_subscription_when_no_subscription(self):
17001726
owner = OwnerFactory(stripe_subscription_id=None)
17011727
assert self.stripe.get_subscription(owner) is None

0 commit comments

Comments
 (0)