From f0c604690f72174a47f4713204673ae94a3b5b3e Mon Sep 17 00:00:00 2001 From: Martin Pentrak Date: Tue, 15 Oct 2024 17:57:04 +0200 Subject: [PATCH] done /adim/api/service/{id}/backend_usages/{id} --- tests/integration/conftest.py | 19 ++++++++++++------- .../test_integration_account_plans.py | 1 + .../test_integration_backend_usages.py | 17 +++++++++++++++++ 3 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 tests/integration/test_integration_backend_usages.py diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 32c2767..bfdb8ab 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -179,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) diff --git a/tests/integration/test_integration_account_plans.py b/tests/integration/test_integration_account_plans.py index c8e1bcd..6f75f8f 100644 --- a/tests/integration/test_integration_account_plans.py +++ b/tests/integration/test_integration_account_plans.py @@ -1,5 +1,6 @@ from tests.integration import asserts + def test_account_plans_list(api, account_plan): account_plans = api.account_plans.list() assert len(account_plans) >= 1 diff --git a/tests/integration/test_integration_backend_usages.py b/tests/integration/test_integration_backend_usages.py new file mode 100644 index 0000000..fdf779e --- /dev/null +++ b/tests/integration/test_integration_backend_usages.py @@ -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)