Skip to content

Commit 4468b33

Browse files
committed
Implement suggested changes from PR review.
1 parent 405ad3c commit 4468b33

File tree

4 files changed

+12
-22
lines changed

4 files changed

+12
-22
lines changed

tests/integration/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ def service_plan_params(service) -> dict:
156156

157157
@pytest.fixture(scope='module')
158158
def service_plan(service, service_plan_params) -> ServicePlan:
159-
160159
resource = service.service_plans.create(params=service_plan_params)
161160
yield resource
161+
cleanup(resource)
162162

163163
@pytest.fixture(scope='module')
164164
def service_subscription_params(service_plan) -> dict:
@@ -169,6 +169,7 @@ def service_subscription_params(service_plan) -> dict:
169169
def service_subscription(account, service_subscription_params) -> ServiceSubscription:
170170
resource = account.service_subscriptions.create(params=service_subscription_params)
171171
yield resource
172+
cleanup(resource)
172173

173174
@pytest.fixture(scope='module')
174175
def application_plan_params() -> dict:

tests/integration/test_integration_service_plans.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
import pytest
21

32

4-
from tests.integration.conftest import service
5-
from threescale_api.errors import ApiClientError
6-
73
from tests.integration import asserts
84

9-
def test_list_service_plans(service, service_plan):
5+
def test_list_service_plans(service):
106
resource = service.service_plans.list()
117
assert len(resource) >= 1
128

13-
def test_check_service_plan_creation(service, service_plan, service_plan_params):
9+
def test_check_service_plan_creation(service_plan, service_plan_params):
1410
asserts.assert_resource(service_plan)
1511
asserts.assert_resource_params(service_plan, service_plan_params)
1612
assert service_plan.exists()
@@ -29,7 +25,7 @@ def test_update_service_plans(service, service_plan, service_plan_params):
2925
asserts.assert_resource(resource)
3026
asserts.assert_resource_params(service_plan, service_plan_params)
3127

32-
def test_set_default_service_plan(service, service_plan, service_plan_params):
28+
def test_set_default_service_plan(service_plan, service_plan_params):
3329
asserts.assert_resource(service_plan)
3430
resource = service_plan.set_default()
3531
asserts.assert_resource(resource)
Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
1-
import pytest
2-
import backoff
31

4-
from tests.integration.conftest import account
5-
from threescale_api.errors import ApiClientError
62

73
from tests.integration import asserts
84

9-
def test_list_service_subscriptions(account, service_subscription):
5+
def test_list_service_subscriptions(account):
106
resource = account.service_subscriptions.list()
117
assert len(resource) >= 1
128

13-
def test_should_create_service_subscription(account, service_subscription, service_subscription_params):
9+
def test_create_service_subscription(service_subscription, service_subscription_params):
1410
asserts.assert_resource(service_subscription)
1511
asserts.assert_resource_params(service_subscription, service_subscription_params)
1612

17-
def test_should_read_service_subscription(account, service_subscription, service_subscription_params):
13+
def test_read_service_subscription(account, service_subscription, service_subscription_params):
1814
resource = account.service_subscriptions.read(service_subscription.entity_id)
1915
asserts.assert_resource(resource)
2016
asserts.assert_resource_params(service_subscription,service_subscription_params)
21-
22-
23-

threescale_api/resources.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,13 +286,13 @@ def __init__(self, *args, entity_name='service_subscription',
286286
def url(self) -> str:
287287
return self.parent.url + '/service_subscriptions'
288288

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

295-
def change_plan_service_subscription(self, entity_id: int, plan_id: int, **kwargs):
295+
def change_plan(self, entity_id: int, plan_id: int, **kwargs):
296296
params = dict(plan_id=plan_id)
297297
url = self.url + f"/{entity_id}/change_plan.json"
298298
response = self.rest.put(url=url, json=params, **kwargs)
@@ -1188,10 +1188,10 @@ class ServiceSubscription(DefaultResource):
11881188
def __init__(self, **kwargs):
11891189
super().__init__(**kwargs)
11901190

1191-
def approve_service_subscription(self, entity_id: int, **kwargs):
1191+
def approve(self, entity_id: int, **kwargs):
11921192
return self.client.approve_service_subscription(entity_id=self.entity_id, **kwargs)
11931193

1194-
def change_plan_service_subscription(self, entity_id: int, **kwargs):
1194+
def change_plan(self, entity_id: int, **kwargs):
11951195
return self.client.change_plan_service_subscription(entity_id=self.entity_id, **kwargs)
11961196

11971197

0 commit comments

Comments
 (0)