diff --git a/tests/unit/test_charm.py b/tests/unit/test_charm.py index 466317386f..6f61f8f2f6 100644 --- a/tests/unit/test_charm.py +++ b/tests/unit/test_charm.py @@ -135,6 +135,7 @@ def test_on_install_snap_failure( _install_snap_packages.assert_called_once() self.assertTrue(isinstance(self.harness.model.unit.status, BlockedStatus)) + @patch_network_get(private_address="1.1.1.1") def test_patroni_scrape_config_no_tls(self): result = self.charm.patroni_scrape_config() @@ -142,11 +143,12 @@ def test_patroni_scrape_config_no_tls(self): { "metrics_path": "/metrics", "scheme": "http", - "static_configs": [{"targets": ["localhost:8008"]}], + "static_configs": [{"targets": ["1.1.1.1:8008"]}], "tls_config": {"insecure_skip_verify": True}, }, ] + @patch_network_get(private_address="1.1.1.1") @patch( "charm.PostgresqlOperatorCharm.is_tls_enabled", return_value=True, @@ -159,7 +161,7 @@ def test_patroni_scrape_config_tls(self, _): { "metrics_path": "/metrics", "scheme": "https", - "static_configs": [{"targets": ["localhost:8008"]}], + "static_configs": [{"targets": ["1.1.1.1:8008"]}], "tls_config": {"insecure_skip_verify": True}, }, ] @@ -1087,6 +1089,7 @@ def test_restart(self, _are_all_members_ready, _restart_postgresql): mock_event.defer.assert_not_called() @patch_network_get(private_address="1.1.1.1") + @patch("charm.time.sleep", return_value=None) @patch("subprocess.check_output", return_value=b"C") @patch("charm.snap.SnapCache") @patch("charms.rolling_ops.v0.rollingops.RollingOpsManager._on_acquire_lock") @@ -1109,6 +1112,7 @@ def test_update_config( _restart, ___, ____, + _____, ): with patch.object(PostgresqlOperatorCharm, "postgresql", Mock()) as postgresql_mock: # Mock some properties.