Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 15 additions & 1 deletion tests/integration/test_integration_service_subscriptions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@


from tests.integration import asserts

def test_list_service_subscriptions(account):
Expand All @@ -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)
6 changes: 3 additions & 3 deletions threescale_api/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading