From 18fd73029267d15eb96c022c03fb859217d390de Mon Sep 17 00:00:00 2001 From: Giuseppe Barbieri Date: Tue, 8 Oct 2024 16:30:00 +0200 Subject: [PATCH] remove unnecessary patch network get --- tests/unit/helpers.py | 23 ----------------------- tests/unit/test_probes_provider.py | 5 ----- 2 files changed, 28 deletions(-) diff --git a/tests/unit/helpers.py b/tests/unit/helpers.py index e6510e8..c4b305a 100644 --- a/tests/unit/helpers.py +++ b/tests/unit/helpers.py @@ -27,29 +27,6 @@ def cli_arg(plan, cli_opt): return opt_list[0] return None - -def patch_network_get(private_address="10.1.157.116") -> Callable: - def network_get(*args, **kwargs) -> dict: - """Patch for the not-yet-implemented testing backend needed for `bind_address`. - - This patch decorator can be used for cases such as: - self.model.get_binding(event.relation).network.bind_address - """ - return { - "bind-addresses": [ - { - "mac-address": "", - "interface-name": "", - "addresses": [{"hostname": "", "value": private_address, "cidr": ""}], - } - ], - "egress-subnets": ["10.152.183.65/32"], - "ingress-addresses": ["10.152.183.65"], - } - - return patch("ops.testing._TestingModelBackend.network_get", network_get) - - k8s_resource_multipatch = patch.multiple( "charm.KubernetesComputeResourcesPatch", _namespace="test-namespace", diff --git a/tests/unit/test_probes_provider.py b/tests/unit/test_probes_provider.py index 49ebd13..cb44e96 100644 --- a/tests/unit/test_probes_provider.py +++ b/tests/unit/test_probes_provider.py @@ -7,7 +7,6 @@ from charms.blackbox_k8s.v0.blackbox_probes import BlackboxProbesProvider from cosl import JujuTopology -from helpers import patch_network_get from ops.charm import CharmBase from ops.framework import StoredState from ops.testing import Harness @@ -90,7 +89,6 @@ def setUp(self): self.harness.set_leader(True) self.harness.begin() - @patch_network_get() def test_provider_sets_scrape_metadata(self): rel_id = self.harness.add_relation(RELATION_NAME, "provider") self.harness.add_relation_unit(rel_id, "provider/0") @@ -105,7 +103,6 @@ def test_provider_sets_scrape_metadata(self): self.assertIn("application", scrape_metadata) self.assertIn("unit", scrape_metadata) - @patch_network_get() def test_provider_sets_probes_on_relation_joined(self): rel_id = self.harness.add_relation(RELATION_NAME, "provider") self.harness.add_relation_unit(rel_id, "provider/0") @@ -118,7 +115,6 @@ def test_provider_sets_probes_on_relation_joined(self): self.assertEqual(scrape_data[0]["static_configs"][0]["targets"], ["10.1.238.1"]) self.assertEqual(scrape_data[0]["params"]["module"], ["http_2xx"]) - @patch_network_get() def test_provider_sets_modules_with_prefix_on_relation_joined(self): rel_id = self.harness.add_relation(RELATION_NAME, "provider") self.harness.add_relation_unit(rel_id, "provider/0") @@ -135,7 +131,6 @@ def test_provider_sets_modules_with_prefix_on_relation_joined(self): self.assertIn(f"{module_name_prefix}http_2xx_longer_timeout", scrape_modules) - @patch_network_get() def test_provider_prefixes_jobs(self): rel_id = self.harness.add_relation(RELATION_NAME, "provider") self.harness.add_relation_unit(rel_id, "provider/0")