From 1d03817b383200322b37ab7389d68f1f4e3b9e2a Mon Sep 17 00:00:00 2001 From: gatici Date: Thu, 7 Dec 2023 22:00:21 +0300 Subject: [PATCH] Fetch new fiveg_nrf library Signed-off-by: gatici --- .../v0/fiveg_nrf.py | 10 +++++----- src/charm.py | 2 +- tests/unit/test_charm.py | 20 +++++++++---------- 3 files changed, 16 insertions(+), 16 deletions(-) rename lib/charms/{sdcore_nrf => sdcore_nrf_k8s}/v0/fiveg_nrf.py (97%) diff --git a/lib/charms/sdcore_nrf/v0/fiveg_nrf.py b/lib/charms/sdcore_nrf_k8s/v0/fiveg_nrf.py similarity index 97% rename from lib/charms/sdcore_nrf/v0/fiveg_nrf.py rename to lib/charms/sdcore_nrf_k8s/v0/fiveg_nrf.py index 2a35036..8342e0a 100644 --- a/lib/charms/sdcore_nrf/v0/fiveg_nrf.py +++ b/lib/charms/sdcore_nrf_k8s/v0/fiveg_nrf.py @@ -13,7 +13,7 @@ From a charm directory, fetch the library using `charmcraft`: ```shell -charmcraft fetch-lib charms.sdcore_nrf.v0.fiveg_nrf +charmcraft fetch-lib charms.sdcore_nrf_k8s.v0.fiveg_nrf ``` Add the following libraries to the charm's `requirements.txt` file: @@ -28,7 +28,7 @@ from ops.charm import CharmBase from ops.main import main -from charms.sdcore_nrf.v0.fiveg_nrf import NRFAvailableEvent, NRFRequires +from charms.sdcore_nrf_k8s.v0.fiveg_nrf import NRFAvailableEvent, NRFRequires logger = logging.getLogger(__name__) @@ -58,7 +58,7 @@ def _on_nrf_available(self, event: NRFAvailableEvent): from ops.charm import CharmBase, RelationJoinedEvent from ops.main import main -from charms.sdcore_nrf.v0.fiveg_nrf import NRFProvides +from charms.sdcore_nrf_k8s.v0.fiveg_nrf import NRFProvides class DummyFiveGNRFProviderCharm(CharmBase): @@ -103,14 +103,14 @@ def _on_nrf_url_changed( from pydantic import AnyHttpUrl, BaseModel, Field, ValidationError # The unique Charmhub library identifier, never change it -LIBID = "cd132a12c2b34243bfd2bae8d08c32d6" +LIBID = "14746bb6f8d34accbeac27ea50ff4715" # Increment this major API version when introducing breaking changes LIBAPI = 0 # Increment this PATCH version before using `charmcraft publish-lib` or reset # to 0 if you are raising the major API version -LIBPATCH = 6 +LIBPATCH = 1 PYDEPS = ["pydantic", "pytest-interface-tester"] diff --git a/src/charm.py b/src/charm.py index 253aa5a..8548964 100755 --- a/src/charm.py +++ b/src/charm.py @@ -10,7 +10,7 @@ from typing import Optional from charms.data_platform_libs.v0.data_interfaces import DatabaseRequires # type: ignore[import] -from charms.sdcore_nrf.v0.fiveg_nrf import NRFRequires # type: ignore[import] +from charms.sdcore_nrf_k8s.v0.fiveg_nrf import NRFRequires # type: ignore[import] from charms.tls_certificates_interface.v2.tls_certificates import ( # type: ignore[import] CertificateAvailableEvent, CertificateExpiringEvent, diff --git a/tests/unit/test_charm.py b/tests/unit/test_charm.py index a112fe7..0b171c5 100644 --- a/tests/unit/test_charm.py +++ b/tests/unit/test_charm.py @@ -155,7 +155,7 @@ def test_given_container_can_connect_and_certificates_relation_is_not_created_wh ) @patch("charm.check_output") - @patch("charms.sdcore_nrf.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) + @patch("charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) @patch("ops.model.Container.restart") def test_given_pcf_charm_in_active_state_when_nrf_relation_breaks_then_status_is_blocked( self, _, patched_nrf_url, patch_check_output @@ -184,7 +184,7 @@ def test_given_pcf_charm_in_active_state_when_nrf_relation_breaks_then_status_is ) @patch("charm.check_output") - @patch("charms.sdcore_nrf.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) + @patch("charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) @patch("ops.model.Container.restart") def test_given_pcf_charm_in_active_state_when_database_relation_breaks_then_status_is_blocked( self, _, patched_nrf_url, patch_check_output @@ -247,7 +247,7 @@ def test_given_container_can_connect_and_fiveg_nrf_relation_is_not_available_whe WaitingStatus("Waiting for NRF endpoint to be available"), ) - @patch("charms.sdcore_nrf.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) + @patch("charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) def test_given_container_storage_is_not_attached_when_configure_sdcore_pcf_then_status_is_waiting( # noqa: E501 self, patched_nrf_url, @@ -268,7 +268,7 @@ def test_given_container_storage_is_not_attached_when_configure_sdcore_pcf_then_ ) @patch("charm.check_output") - @patch("charms.sdcore_nrf.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) + @patch("charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) def test_given_certificate_is_not_stored_when_configure_sdcore_pcf_then_status_is_waiting( # noqa: E501 self, patched_nrf_url, @@ -292,7 +292,7 @@ def test_given_certificate_is_not_stored_when_configure_sdcore_pcf_then_status_i ) @patch("charm.check_output") - @patch("charms.sdcore_nrf.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) + @patch("charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) def test_given_config_file_is_not_written_when_configure_sdcore_pcf_is_called_then_config_file_is_written_with_expected_content( # noqa: E501 self, patched_nrf_url, patch_check_output ): @@ -320,7 +320,7 @@ def test_given_config_file_is_not_written_when_configure_sdcore_pcf_is_called_th ) @patch("charm.check_output") - @patch("charms.sdcore_nrf.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) + @patch("charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) def test_given_config_file_is_written_and_is_not_changed_when_configure_sdcore_pcf_is_called_then_config_file_is_not_written( # noqa: E501 self, patched_nrf_url, patch_check_output ): @@ -349,7 +349,7 @@ def test_given_config_file_is_written_and_is_not_changed_when_configure_sdcore_p (root / f"etc/pcf/{CONFIG_FILE_NAME}").stat().st_mtime, config_modification_time ) - @patch("charms.sdcore_nrf.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) + @patch("charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) @patch("charm.check_output") def test_given_config_file_exists_and_is_changed_when_configure_pcf_then_config_file_is_updated( # noqa: E501 self, @@ -379,7 +379,7 @@ def test_given_config_file_exists_and_is_changed_when_configure_pcf_then_config_ (root / f"etc/pcf/{CONFIG_FILE_NAME}").read_text(), expected_content.strip() ) - @patch("charms.sdcore_nrf.v0.fiveg_nrf.NRFRequires.nrf_url") + @patch("charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequires.nrf_url") @patch("charm.check_output") def test_given_config_files_and_relations_are_created_when_configure_sdcore_pcf_is_called_then_expected_plan_is_applied( # noqa: E501 self, patch_check_output, patch_nrf_url @@ -422,7 +422,7 @@ def test_given_config_files_and_relations_are_created_when_configure_sdcore_pcf_ self.assertEqual(expected_plan, updated_plan) @patch("charm.check_output") - @patch("charms.sdcore_nrf.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) + @patch("charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) @patch("ops.model.Container.restart") def test_given_config_file_is_written_when_configure_sdcore_pcf_is_called_then_status_is_active( # noqa: E501 self, _, patched_nrf_url, patch_check_output @@ -449,7 +449,7 @@ def test_given_config_file_is_written_when_configure_sdcore_pcf_is_called_then_s @patch("ops.model.Container.restart", new=Mock) @patch("charm.check_output") - @patch("charms.sdcore_nrf.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) + @patch("charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequires.nrf_url", new_callable=PropertyMock) def test_given_ip_not_available_when_configure_then_status_is_waiting( self, _, patch_check_output ):