Skip to content

Commit 788fea9

Browse files
author
mkudlej
authored
Merge pull request #167 from josemacassan/service_subscription
Add tests into ServiceSubscriptions resource.
2 parents 7e73dd3 + 4a9f2b5 commit 788fea9

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

tests/integration/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def account_user(account,account_user_params) -> AccountUser:
152152
@pytest.fixture(scope='module')
153153
def service_plan_params() -> dict:
154154
suffix = get_suffix()
155-
return {"name":f'test-{suffix}'}
155+
return {"name":f'test-{suffix}', "approval_required": True}
156156

157157
@pytest.fixture(scope='module')
158158
def service_plan(service, service_plan_params) -> ServicePlan:

tests/integration/test_integration_service_subscriptions.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11

2-
32
from tests.integration import asserts
43

54
def test_list_service_subscriptions(account):
@@ -14,3 +13,18 @@ def test_read_service_subscription(account, service_subscription, service_subscr
1413
resource = account.service_subscriptions.read(service_subscription.entity_id)
1514
asserts.assert_resource(resource)
1615
asserts.assert_resource_params(service_subscription,service_subscription_params)
16+
17+
def test_change_plan_service_subscription(account, account_plan, service_plan,
18+
service_subscription):
19+
asserts.assert_resource(account)
20+
asserts.assert_resource(account_plan)
21+
asserts.assert_resource(service_plan)
22+
account.service_subscriptions.change_plan(service_subscription.entity_id,
23+
service_plan.entity_id)
24+
25+
def test_approve_service_subscription(account, service_subscription, service_plan):
26+
asserts.assert_resource(service_subscription)
27+
asserts.assert_resource(account)
28+
asserts.assert_resource(service_plan)
29+
resource = service_subscription.approve()
30+
asserts.assert_resource(resource)

threescale_api/resources.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,14 +286,14 @@ def url(self) -> str:
286286
return self.parent.url + '/service_subscriptions'
287287

288288
def approve(self, entity_id: int, **kwargs):
289-
url = self.url + f"/{entity_id}/approve.json"
289+
url = self.url + f"/{entity_id}/approve"
290290
response = self.rest.put(url=url, **kwargs)
291-
instance = utils.extract_response(response=response)
291+
instance = self._create_instance(response=response)
292292
return instance
293293

294294
def change_plan(self, entity_id: int, plan_id: int, **kwargs):
295295
params = {"plan_id": plan_id}
296-
url = self.url + f"/{entity_id}/change_plan.json"
296+
url = self.url + f"/{entity_id}/change_plan"
297297
response = self.rest.put(url=url, json=params, **kwargs)
298298
instance = utils.extract_response(response=response)
299299
return instance

0 commit comments

Comments
 (0)