Skip to content

Commit

Permalink
add get all applications plans test
Browse files Browse the repository at this point in the history
GET /admin/api/application_plans
  • Loading branch information
Gituser010 committed Sep 30, 2024
1 parent d2ff206 commit 18b8a37
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
7 changes: 6 additions & 1 deletion tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
Proxy, Backend, Metric, MappingRule,
BackendMappingRule, BackendUsage,
ActiveDoc, Webhooks, InvoiceState,
ApplicationKey)
ApplicationKey, ApplicationPlans)

load_dotenv()

Expand Down Expand Up @@ -127,6 +127,11 @@ def application_plan(api, service, application_plan_params) -> ApplicationPlan:
resource = service.app_plans.create(params=application_plan_params)
yield resource

@pytest.fixture(scope='module')
def application_plans(api) -> ApplicationPlans:
application_plans = api.application_plans
yield application_plans


@pytest.fixture(scope='module')
def application_params(application_plan):
Expand Down
5 changes: 5 additions & 0 deletions tests/integration/test_integration_application_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ def test_application_plans_list(service):
assert len(app_plans) == 1


def test_application_plans_list_all(application_plans):
app_plans = application_plans.list()
assert len(app_plans) >= 1


def test_application_plan_update(application_plan, update_params):
updated_app_plan = application_plan.update(params=update_params)
asserts.assert_resource(updated_app_plan)
Expand Down
8 changes: 8 additions & 0 deletions threescale_api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__(self, url: str, token: str,
self._access_tokens = \
resources.AccessTokens(self, instance_klass=resources.AccessToken)
self._active_docs = resources.ActiveDocs(self, instance_klass=resources.ActiveDoc)
self._application_plans =resources.ApplicationPlans(self, instance_klass=resources.ApplicationPlan)
self._account_plans = resources.AccountPlans(self, instance_klass=resources.AccountPlan)
self._settings = resources.SettingsClient(self)
self._admin_portal_auth_providers = resources.AdminPortalAuthProviders(
Expand Down Expand Up @@ -142,6 +143,13 @@ def master_api_url(self) -> str:
"""
return self.url + "/master/api"

@property
def application_plans(self) -> resources.ApplicationPlans:
"""Get applications_plan client
Returns(resources.ApplicationPlans): ApplicationPlans client
"""
return self._application_plans

@property
def services(self) -> resources.Services:
"""Gets services client
Expand Down
4 changes: 3 additions & 1 deletion threescale_api/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ def __init__(self, *args, entity_name='application_plan', entity_collection='pla

@property
def url(self) -> str:
return self.parent.url + '/application_plans'
if type(self.parent) is Service:
return self.parent.url + '/application_plans'
return self.threescale_client.admin_api_url +'/application_plans'

@property
def plans_url(self) -> str:
Expand Down

0 comments on commit 18b8a37

Please sign in to comment.