Skip to content

Commit

Permalink
Add api calls test for empty given count
Browse files Browse the repository at this point in the history
  • Loading branch information
zachaysan committed May 13, 2024
1 parent 5061750 commit 9ed8615
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions api/organisations/chargebee/__init__.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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()

0 comments on commit 9ed8615

Please sign in to comment.