Files
charm-ceph-mon/unit_tests/helpers.py
Peter Sabaini e36a1890b4 Fix: make ceph_metrics test more robust
Instead of messing with the harness' construction patch the missing
network-get in place

Change-Id: I162a0b73d76a3ed18689c2baf258372efe5f2ec4
2022-09-29 15:14:41 +02:00

24 lines
728 B
Python

# Copyright 2020 Canonical Ltd.
# See LICENSE file for licensing details.
from typing import Callable
from unittest.mock import patch
def patch_network_get(private_address="10.0.0.10") -> 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": [
{
"addresses": [{"value": private_address}],
}
],
}
return patch("ops.testing._TestingModelBackend.network_get", network_get)