Skip to content

Commit

Permalink
Fetch new fiveg_nrf library
Browse files Browse the repository at this point in the history
Signed-off-by: gatici <gulsum.atici@canonical.com>
  • Loading branch information
gatici committed Dec 7, 2023
1 parent 375e45f commit 1d03817
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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__)
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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"]

Expand Down
2 changes: 1 addition & 1 deletion src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
20 changes: 10 additions & 10 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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
):
Expand Down Expand Up @@ -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
):
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
):
Expand Down

0 comments on commit 1d03817

Please sign in to comment.