Skip to content

Commit

Permalink
Migrate to use version checker as a pip package (#424)
Browse files Browse the repository at this point in the history
## Issue
version checking should be made available to all charms

## Solution
migrate version checking to pip package
  • Loading branch information
MiaAltieri authored Jun 25, 2024
1 parent 5b277c3 commit b653333
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 250 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
attrs==23.2.0
cffi==1.16.0
cosl==0.0.11
data-platform-helpers==0.1.1
importlib-resources==6.4.0
tenacity==8.2.3
pymongo==4.6.3
Expand Down
6 changes: 5 additions & 1 deletion src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
)
from charms.operator_libs_linux.v1.systemd import service_running
from charms.operator_libs_linux.v2 import snap
from data_platform_helpers.version_check import (
CrossAppVersionChecker,
NoVersionError,
get_charm_revision,
)
from ops.charm import (
ActionEvent,
CharmBase,
Expand Down Expand Up @@ -84,7 +89,6 @@
update_mongod_service,
)
from upgrades.mongodb_upgrade import MongoDBUpgrade
from version_check import CrossAppVersionChecker, NoVersionError, get_charm_revision

AUTH_FAILED_CODE = 18
UNAUTHORISED_CODE = 13
Expand Down
244 changes: 0 additions & 244 deletions src/version_check.py

This file was deleted.

6 changes: 4 additions & 2 deletions tests/unit/test_config_server_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ def is_config_mock_call(*args):
self.harness.charm.cluster.update_config_server_db(mock.Mock())
self.harness.charm.cluster.database_provides.update_relation_data.assert_not_called()

@mock.patch("version_check.CrossAppVersionChecker.is_local_charm")
@mock.patch("version_check.CrossAppVersionChecker.is_integrated_to_locally_built_charm")
@mock.patch("data_platform_helpers.version_check.CrossAppVersionChecker.is_local_charm")
@mock.patch(
"data_platform_helpers.version_check.CrossAppVersionChecker.is_integrated_to_locally_built_charm"
)
@mock.patch("charm.get_charm_revision")
def test_pass_hooks_check_waits_for_start_config_server(
self,
Expand Down
6 changes: 4 additions & 2 deletions tests/unit/test_mongodb_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@ def test_relation_event_oversee_users_mongo_failure(

# oversee_users raises AssertionError when unable to attain users from relation
@patch_network_get(private_address="1.1.1.1")
@patch("version_check.CrossAppVersionChecker.is_local_charm")
@patch("version_check.CrossAppVersionChecker.is_integrated_to_locally_built_charm")
@patch("data_platform_helpers.version_check.CrossAppVersionChecker.is_local_charm")
@patch(
"data_platform_helpers.version_check.CrossAppVersionChecker.is_integrated_to_locally_built_charm"
)
@patch("charm.get_charm_revision")
@patch("ops.framework.EventBase.defer")
@patch("charm.MongoDBProvider.oversee_users")
Expand Down
6 changes: 5 additions & 1 deletion tests/unit/test_version_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
import unittest
from unittest.mock import patch

from data_platform_helpers.version_check import (
DEPLOYMENT_TYPE,
VERSION_CONST,
NoVersionError,
)
from ops.testing import Harness

from charm import MongodbOperatorCharm
from version_check import DEPLOYMENT_TYPE, VERSION_CONST, NoVersionError

from .helpers import patch_network_get

Expand Down

0 comments on commit b653333

Please sign in to comment.