From 3e9d6ca470410f532cb548304c389d09d337a5f2 Mon Sep 17 00:00:00 2001 From: Martin Kudlej Date: Wed, 22 Nov 2023 16:28:39 +0100 Subject: [PATCH] add ssl verify value from fixture, change methods to hits as a parent, metric cannot be deleted if it is part of deployed proxy --- tests/integration/conftest.py | 5 ++++- tests/integration/test_integration_methods.py | 10 +++++----- tests/integration/test_integration_tenant.py | 16 ++++++++-------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index b70c0b3..876970a 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -360,12 +360,15 @@ def backend(backend_params, api) -> Backend: cleanup(backend) @pytest.fixture(scope='module') -def backend_metric(backend, metric_params) -> Metric: +def backend_metric(backend, metric_params, proxy) -> Metric: """ Fixture for getting backend metric. """ resource = backend.metrics.create(params=metric_params) yield resource + for map_rule in backend.mapping_rules.select_by(metric_id=resource['id']): + map_rule.delete() + proxy.deploy() cleanup(resource) @pytest.fixture(scope="module") diff --git a/tests/integration/test_integration_methods.py b/tests/integration/test_integration_methods.py index 7256a50..eb6d256 100644 --- a/tests/integration/test_integration_methods.py +++ b/tests/integration/test_integration_methods.py @@ -4,17 +4,17 @@ from tests.integration import asserts -def test_list_methods(metric, method): - assert len(metric.methods.list()) >= 1 +def test_list_methods(hits_metric, method): + assert len(hits_metric.methods.list()) >= 1 def test_should_create_method(method, method_params): asserts.assert_resource(method) asserts.assert_resource_params(method, method_params) -def test_should_not_create_method_for_custom_metric(metric, method_params): - resource = metric.methods.create(params=method_params, throws=False) - asserts.assert_errors_contains(resource, ['parent_id']) +def test_should_not_create_method_for_custom_metric(hits_metric, method_params): + resource = hits_metric.methods.create(params=method_params, throws=False) + asserts.assert_errors_contains(resource, ['system_name']) def test_should_friendly_name_be_required(hits_metric): diff --git a/tests/integration/test_integration_tenant.py b/tests/integration/test_integration_tenant.py index e0b2f71..199fcd0 100644 --- a/tests/integration/test_integration_tenant.py +++ b/tests/integration/test_integration_tenant.py @@ -40,29 +40,29 @@ def count_invoice(api, account): return len(api.invoices.list_by_account(account)) -def test_trigger_billing(master_api, custom_tenant, paid_account, next_day): - api = custom_tenant.admin_api(wait=True) +def test_trigger_billing(master_api, custom_tenant, paid_account, next_day, ssl_verify): + api = custom_tenant.admin_api(ssl_verify=ssl_verify, wait=True) account = paid_account(api) assert master_api.tenants.trigger_billing(custom_tenant, next_day) assert count_invoice(api, account) == 1 -def test_trigger_billing_resource(custom_tenant, paid_account, next_day): - api = custom_tenant.admin_api(wait=True) +def test_trigger_billing_resource(custom_tenant, paid_account, next_day, ssl_verify): + api = custom_tenant.admin_api(ssl_verify=ssl_verify, wait=True) account = paid_account(api) assert custom_tenant.trigger_billing(next_day) assert count_invoice(api, account) == 1 -def test_trigger_billing_account(master_api, custom_tenant, paid_account, next_day): - api = custom_tenant.admin_api(wait=True) +def test_trigger_billing_account(master_api, custom_tenant, paid_account, next_day, ssl_verify): + api = custom_tenant.admin_api(ssl_verify=ssl_verify, wait=True) account = paid_account(api) assert master_api.tenants.trigger_billing_account(custom_tenant, account, next_day) assert count_invoice(api, account) == 1 -def test_trigger_billing_account_resource(custom_tenant, paid_account, next_day): - api = custom_tenant.admin_api(wait=True) +def test_trigger_billing_account_resource(custom_tenant, paid_account, next_day, ssl_verify): + api = custom_tenant.admin_api(ssl_verify=ssl_verify, wait=True) account = paid_account(api) assert custom_tenant.trigger_billing_account(account, next_day) assert count_invoice(api, account) == 1