-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #162 from Gituser010/master
extended api tests
- Loading branch information
Showing
8 changed files
with
129 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
Proxy, Backend, Metric, MappingRule, | ||
BackendMappingRule, BackendUsage, | ||
ActiveDoc, Webhooks, InvoiceState, | ||
ApplicationKey) | ||
ApplicationKey, ApplicationPlans) | ||
|
||
load_dotenv() | ||
|
||
|
@@ -102,6 +102,13 @@ def access_token(access_token_params, api): | |
cleanup(entity) | ||
|
||
|
||
@pytest.fixture(scope='module') | ||
def update_account_params(): | ||
suffix = secrets.token_urlsafe(8) | ||
name = f"updated-{suffix}" | ||
return dict(name=name, username=name, org_name=name) | ||
|
||
|
||
@pytest.fixture(scope='module') | ||
def account_params(): | ||
suffix = get_suffix() | ||
|
@@ -127,6 +134,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): | ||
|
@@ -167,13 +179,18 @@ def proxy(service, application, api_backend) -> Proxy: | |
|
||
|
||
@pytest.fixture(scope='module') | ||
def backend_usage(service, backend, application) -> BackendUsage: | ||
params = { | ||
'service_id': service['id'], | ||
'backend_api_id': backend['id'], | ||
'path': '/get', | ||
} | ||
resource = service.backend_usages.create(params=params) | ||
def backend_usage_update_params(service, backend): | ||
return dict(service_id=service['id'], backend_api_id=backend['id'], path='/put') | ||
|
||
|
||
@pytest.fixture(scope='module') | ||
def backend_usage_params(service, backend): | ||
return dict(service_id=service['id'], backend_api_id=backend['id'], path='/get') | ||
|
||
|
||
@pytest.fixture(scope='module') | ||
def backend_usage(service, backend, application, backend_usage_params) -> BackendUsage: | ||
resource = service.backend_usages.create(params=backend_usage_params) | ||
yield resource | ||
cleanup(resource) | ||
|
||
|
@@ -422,6 +439,22 @@ def tenant_params(): | |
email="[email protected]", | ||
org_name="org") | ||
|
||
|
||
@pytest.fixture(scope='module') | ||
def active_docs_update_body(): | ||
return """ | ||
{"swagger":"2.0","info":{"version":"1.0.1","title":"Test"},"paths":{"/test":{"get":{"operationId":"Test", | ||
"parameters":[],"responses":{"400":{"description":"bad input parameters"}}}}},"definitions":{}} | ||
""" | ||
|
||
|
||
@pytest.fixture(scope='module') | ||
def active_docs_update_params(active_docs_update_body): | ||
suffix = get_suffix() | ||
name = f"updated-{suffix}" | ||
return dict(name=name, body=active_docs_update_body) | ||
|
||
|
||
@pytest.fixture(scope='module') | ||
def active_docs_body(): | ||
return """ | ||
|
@@ -477,6 +510,13 @@ def webhook(api): | |
return api.webhooks | ||
|
||
|
||
@pytest.fixture(scope='module') | ||
def account_plans_update_params(): | ||
suffix = secrets.token_urlsafe(8) | ||
name = f"updated-{suffix}" | ||
return dict(name=name, description=name) | ||
|
||
|
||
@pytest.fixture(scope='module') | ||
def account_plans_params(): | ||
suffix = get_suffix() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from tests.integration import asserts | ||
|
||
|
||
def test_account_plans_list(api, account_plan): | ||
account_plans = api.account_plans.list() | ||
assert len(account_plans) >= 1 | ||
|
||
|
||
def test_account_plan_can_be_created(api, account_plan, account_plans_params): | ||
asserts.assert_resource(account_plan) | ||
asserts.assert_resource_params(account_plan, account_plans_params) | ||
|
||
|
||
def test_account_plan_update(account_plan, account_plans_update_params): | ||
updated_account_plan = account_plan.update(params=account_plans_update_params) | ||
asserts.assert_resource(updated_account_plan) | ||
asserts.assert_resource_params(updated_account_plan, account_plans_update_params) | ||
|
||
|
||
def test_account_plan_can_be_read(api, account_plan, account_plans_params): | ||
read = api.account_plans.read(account_plan.entity_id) | ||
asserts.assert_resource(read) | ||
asserts.assert_resource_params(read, account_plans_params) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,23 @@ | ||
from tests.integration import asserts | ||
from .asserts import assert_resource, assert_resource_params | ||
|
||
|
||
def test_active_docs_can_be_created(active_doc, active_docs_params): | ||
asserts.assert_resource(active_doc) | ||
asserts.assert_resource_params(active_doc, active_docs_params) | ||
|
||
|
||
def test_active_docs_fetch(active_doc): | ||
ac = active_doc.client.fetch(int(active_doc['id'])) | ||
assert ac | ||
assert ac['id'] == active_doc['id'] | ||
|
||
|
||
def test_active_docs_list(api, active_doc): | ||
active_docs = api.active_docs.list() | ||
assert len(active_docs) >= 1 | ||
|
||
|
||
def test_active_docs_update(active_doc, active_docs_update_params): | ||
updated_active_doc = active_doc.update(params=active_docs_update_params) | ||
asserts.assert_resource(updated_active_doc) | ||
asserts.assert_resource_params(updated_active_doc, active_docs_update_params) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from tests.integration import asserts | ||
from tests.integration.conftest import backend | ||
|
||
|
||
def test_backend_usage_can_be_created(backend_usage, backend_usage_params): | ||
asserts.assert_resource(backend_usage) | ||
asserts.assert_resource_params(backend_usage, backend_usage_params) | ||
|
||
|
||
def test_backend_usages_list(api, backend_usage, backend): | ||
assert len(backend.usages()) >= 1 | ||
|
||
|
||
def test_backend_usage_update(backend_usage, backend, backend_usage_update_params): | ||
updated_backend_usage = backend_usage.update(backend_usage_update_params) | ||
asserts.assert_resource(updated_backend_usage) | ||
asserts.assert_resource_params(updated_backend_usage, backend_usage_update_params) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters