Skip to content

Commit

Permalink
remove unnecessary patch network get
Browse files Browse the repository at this point in the history
  • Loading branch information
giusebar committed Oct 8, 2024
1 parent ce8e4df commit 18fd730
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 28 deletions.
23 changes: 0 additions & 23 deletions tests/unit/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 0 additions & 5 deletions tests/unit/test_probes_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand All @@ -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")
Expand All @@ -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")
Expand All @@ -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")
Expand Down

0 comments on commit 18fd730

Please sign in to comment.