diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index ebc2147..f7b7720 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -152,7 +152,7 @@ def account_user(account,account_user_params) -> AccountUser: @pytest.fixture(scope='module') def service_plan_params() -> dict: suffix = get_suffix() - return {"name":f'test-{suffix}'} + return {"name":f'test-{suffix}', "approval_required": True} @pytest.fixture(scope='module') def service_plan(service, service_plan_params) -> ServicePlan: diff --git a/tests/integration/test_integration_service_subscriptions.py b/tests/integration/test_integration_service_subscriptions.py index e2c9a5a..5e07441 100644 --- a/tests/integration/test_integration_service_subscriptions.py +++ b/tests/integration/test_integration_service_subscriptions.py @@ -1,5 +1,4 @@ - from tests.integration import asserts def test_list_service_subscriptions(account): @@ -14,3 +13,18 @@ def test_read_service_subscription(account, service_subscription, service_subscr resource = account.service_subscriptions.read(service_subscription.entity_id) asserts.assert_resource(resource) asserts.assert_resource_params(service_subscription,service_subscription_params) + +def test_change_plan_service_subscription(account, account_plan, service_plan, + service_subscription): + asserts.assert_resource(account) + asserts.assert_resource(account_plan) + asserts.assert_resource(service_plan) + account.service_subscriptions.change_plan(service_subscription.entity_id, + service_plan.entity_id) + +def test_approve_service_subscription(account, service_subscription, service_plan): + asserts.assert_resource(service_subscription) + asserts.assert_resource(account) + asserts.assert_resource(service_plan) + resource = service_subscription.approve() + asserts.assert_resource(resource) diff --git a/threescale_api/resources.py b/threescale_api/resources.py index 8306e0e..357e9b5 100644 --- a/threescale_api/resources.py +++ b/threescale_api/resources.py @@ -286,14 +286,14 @@ def url(self) -> str: return self.parent.url + '/service_subscriptions' def approve(self, entity_id: int, **kwargs): - url = self.url + f"/{entity_id}/approve.json" + url = self.url + f"/{entity_id}/approve" response = self.rest.put(url=url, **kwargs) - instance = utils.extract_response(response=response) + instance = self._create_instance(response=response) return instance def change_plan(self, entity_id: int, plan_id: int, **kwargs): params = {"plan_id": plan_id} - url = self.url + f"/{entity_id}/change_plan.json" + url = self.url + f"/{entity_id}/change_plan" response = self.rest.put(url=url, json=params, **kwargs) instance = utils.extract_response(response=response) return instance