From 9ed8615ae008b9b0bd14565e2015b7d4a9804c40 Mon Sep 17 00:00:00 2001 From: Zach Aysan Date: Mon, 13 May 2024 13:35:55 +0000 Subject: [PATCH] Add api calls test for empty given count --- api/organisations/chargebee/__init__.py | 1 + .../test_unit_chargebee_chargebee.py | 24 ++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/api/organisations/chargebee/__init__.py b/api/organisations/chargebee/__init__.py index cf03c4f2a052..a12b60779abb 100644 --- a/api/organisations/chargebee/__init__.py +++ b/api/organisations/chargebee/__init__.py @@ -1,4 +1,5 @@ from .chargebee import ( # noqa + add_1000_api_calls, add_1000_api_calls_scale_up, add_1000_api_calls_start_up, add_single_seat, diff --git a/api/tests/unit/organisations/chargebee/test_unit_chargebee_chargebee.py b/api/tests/unit/organisations/chargebee/test_unit_chargebee_chargebee.py index d5cea88097f6..1ef2c45c7502 100644 --- a/api/tests/unit/organisations/chargebee/test_unit_chargebee_chargebee.py +++ b/api/tests/unit/organisations/chargebee/test_unit_chargebee_chargebee.py @@ -4,9 +4,11 @@ import pytest from _pytest.monkeypatch import MonkeyPatch from chargebee import APIError +from pytest_mock import MockerFixture from pytz import UTC from organisations.chargebee import ( + add_1000_api_calls, add_single_seat, extract_subscription_metadata, get_customer_id_from_subscription_id, @@ -19,7 +21,10 @@ get_subscription_metadata_from_id, ) from organisations.chargebee.chargebee import cancel_subscription -from organisations.chargebee.constants import ADDITIONAL_SEAT_ADDON_ID +from organisations.chargebee.constants import ( + ADDITIONAL_API_SCALE_UP_ADDON_ID, + ADDITIONAL_SEAT_ADDON_ID, +) from organisations.chargebee.metadata import ChargebeeObjMetadata from organisations.subscriptions.exceptions import ( CannotCancelChargebeeSubscription, @@ -595,3 +600,20 @@ def test_add_single_seat_throws_upgrade_seats_error_error_if_api_error( == "Failed to add additional seat to CB subscription for subscription id: %s" % subscription_id ) + + +def test_add_1000_api_calls_when_count_is_empty(mocker: MockerFixture) -> None: + # Given + subscription_mock = mocker.patch("chargebee.Subscription.update") + + # When + result = add_1000_api_calls( + addon_id=ADDITIONAL_API_SCALE_UP_ADDON_ID, + subscription_id="subscription23", + count=0, + invoice_immediately=True, + ) + + # Then + assert result is None + subscription_mock.assert_not_called()