3535)
3636from organisations .chargebee .constants import (
3737 ADDITIONAL_API_SCALE_UP_ADDON_ID ,
38- ADDITIONAL_SEAT_ADDON_ID ,
3938)
4039from organisations .chargebee .metadata import ChargebeeObjMetadata
4140from organisations .subscriptions .exceptions import (
@@ -514,7 +513,7 @@ def test_get_subscription_metadata_from_id__addons_is_none__returns_plan_metadat
514513def test_add_single_seat__existing_addon__increments_quantity (mocker ) -> None : # type: ignore[no-untyped-def]
515514 # Given
516515 plan_id = "plan-id"
517- addon_id = ADDITIONAL_SEAT_ADDON_ID
516+ addon_id = "additional-team-members-scale-up-v2-monthly"
518517 subscription_id = "subscription-id"
519518 addon_quantity = 1
520519
@@ -523,6 +522,7 @@ def test_add_single_seat__existing_addon__increments_quantity(mocker) -> None:
523522 id = subscription_id ,
524523 plan_id = plan_id ,
525524 addons = [mocker .MagicMock (id = addon_id , quantity = addon_quantity )],
525+ billing_period = 1 ,
526526 )
527527 mocked_chargebee = mocker .patch (
528528 "organisations.chargebee.chargebee.chargebee_client" , autospec = True
@@ -542,7 +542,7 @@ def test_add_single_seat__existing_addon__increments_quantity(mocker) -> None:
542542 SubscriptionOps .UpdateParams (
543543 addons = [
544544 SubscriptionOps .UpdateAddonParams (
545- id = ADDITIONAL_SEAT_ADDON_ID , quantity = addon_quantity + 1
545+ id = addon_id , quantity = addon_quantity + 1
546546 )
547547 ],
548548 prorate = True ,
@@ -551,8 +551,19 @@ def test_add_single_seat__existing_addon__increments_quantity(mocker) -> None:
551551 )
552552
553553
554- def test_add_single_seat__no_existing_addon__creates_addon_with_quantity_one ( # type: ignore[no-untyped-def]
555- mocker ,
554+ @pytest .mark .parametrize (
555+ "billing_period,expected_add_on_id" ,
556+ (
557+ (1 , "additional-team-members-scale-up-v2-monthly" ),
558+ (6 , "additional-team-members-scale-up-v2-semiannual" ),
559+ (12 , "additional-team-members-scale-up-v2-annual" ),
560+ # unexpected or missing billing period should default to monthly
561+ (None , "additional-team-members-scale-up-v2-monthly" ),
562+ (7 , "additional-team-members-scale-up-v2-monthly" ),
563+ ),
564+ )
565+ def test_add_single_seat__no_existing_addon__creates_addon_with_quantity_one (
566+ mocker : MockerFixture , billing_period : int , expected_add_on_id : str
556567) -> None :
557568 # Given
558569 subscription_id = "subscription-id"
@@ -562,6 +573,7 @@ def test_add_single_seat__no_existing_addon__creates_addon_with_quantity_one( #
562573 id = subscription_id ,
563574 plan_id = "plan_id" ,
564575 addons = [],
576+ billing_period = billing_period ,
565577 )
566578 mocked_chargebee = mocker .patch (
567579 "organisations.chargebee.chargebee.chargebee_client" , autospec = True
@@ -580,9 +592,7 @@ def test_add_single_seat__no_existing_addon__creates_addon_with_quantity_one( #
580592 subscription_id ,
581593 SubscriptionOps .UpdateParams (
582594 addons = [
583- SubscriptionOps .UpdateAddonParams (
584- id = ADDITIONAL_SEAT_ADDON_ID , quantity = 1
585- )
595+ SubscriptionOps .UpdateAddonParams (id = expected_add_on_id , quantity = 1 )
586596 ],
587597 prorate = True ,
588598 invoice_immediately = True ,
@@ -616,6 +626,7 @@ def test_add_single_seat__api_error__raises_upgrade_seats_error( # type: ignore
616626 id = subscription_id ,
617627 plan_id = "plan-id" ,
618628 addons = [],
629+ billing_period = 1 ,
619630 )
620631
621632 # tie that subscription object to the mocked chargebee object
@@ -633,7 +644,7 @@ def test_add_single_seat__api_error__raises_upgrade_seats_error( # type: ignore
633644 SubscriptionOps .UpdateParams (
634645 addons = [
635646 SubscriptionOps .UpdateAddonParams (
636- id = ADDITIONAL_SEAT_ADDON_ID , quantity = 1
647+ id = "additional-team-members-scale-up-v2-monthly" , quantity = 1
637648 )
638649 ],
639650 prorate = True ,
0 commit comments