Skip to content

Commit

Permalink
update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MiaAltieri committed Dec 12, 2023
1 parent 3288dda commit b2f9d9f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tests/unit/test_config_server_lib.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.
import unittest
from unittest.mock import patch
from unittest import mock

from ops.testing import Harness

Expand All @@ -22,8 +22,7 @@ def setUp(self):
self.charm = self.harness.charm
self.addCleanup(self.harness.cleanup)

@patch("charm.ClusterProvider.update_relation_data")
def test_on_relation_joined_failed_hook_checks(self, update_relation_data):
def test_on_relation_joined_failed_hook_checks(self):
"""Tests that no relation data is set when cluster joining conditions are not met."""

def is_not_config_mock_call(*args):
Expand All @@ -36,7 +35,8 @@ def is_not_config_mock_call(*args):
self.harness.charm.is_role = is_not_config_mock_call
relation_id = self.harness.add_relation("cluster", "mongos")
self.harness.add_relation_unit(relation_id, "mongos/0")
update_relation_data.assert_not_called()
self.harness.charm.cluster.database_provides.update_relation_data = mock.Mock()
self.harness.charm.cluster.database_provides.update_relation_data.assert_not_called()

# fails because db has not been initialized
del self.harness.charm.app_peer_data["db_initialised"]
Expand All @@ -47,9 +47,9 @@ def is_config_mock_call(*args):

self.harness.charm.is_role = is_config_mock_call
self.harness.add_relation_unit(relation_id, "mongos/1")
update_relation_data.assert_not_called()
self.harness.charm.cluster.database_provides.update_relation_data.assert_not_called()

# fails because not leader
self.harness.set_leader(False)
self.harness.add_relation_unit(relation_id, "mongos/2")
update_relation_data.assert_not_called()
self.harness.charm.cluster.database_provides.update_relation_data.assert_not_called()

0 comments on commit b2f9d9f

Please sign in to comment.