Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
19 changes: 19 additions & 0 deletions tests/integration/test_integration_service_subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,22 @@ 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_subscription):
asserts.assert_resource(account)
asserts.assert_resource(account_plan)
resource = account.service_subscriptions.change_plan(service_subscription.entity_id,
account_plan.entity_id)
asserts.assert_resource(resource)


# TODO: https://issues.redhat.com/browse/THREESCALE-11693
def test_approve_service_subscription(account, service_subscription,service_subscription_params):
asserts.assert_resource(service_subscription)
service_subscription['state'] = 'pending'
account.service_subscriptions.update(service_subscription.entity_id,
service_subscription_params)
resource = account.service_subscriptions.approve(service_subscription.entity_id)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to simplified this line.

asserts.assert_resource(resource)
asserts.assert_resource_params(service_subscription, service_subscription_params)
6 changes: 3 additions & 3 deletions threescale_api/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,15 @@ 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)
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"
response = self.rest.put(url=url, json=params, **kwargs)
url = self.url + f"/{entity_id}/change_plan"
response = self.rest.put(url=url, params=params)
instance = utils.extract_response(response=response)
return instance

Expand Down