Skip to content

Commit

Permalink
Add fiveg_nrf_k8s library to charm
Browse files Browse the repository at this point in the history
Signed-off-by: gatici <[email protected]>
  • Loading branch information
gatici committed Dec 7, 2023
1 parent fa6c210 commit ed7e984
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
with:
filters: |
fiveg_nrf:
- 'lib/charms/sdcore_nrf/v0/fiveg_nrf.py'
- 'lib/charms/sdcore_nrf_k8s/v0/fiveg_nrf.py'
publish-lib:
name: Publish Lib
Expand All @@ -63,5 +63,5 @@ jobs:
if: ${{ github.ref_name == 'main' }} && ${{ needs.changes.outputs.needs-publishing == 'true' }}
uses: canonical/sdcore-github-workflows/.github/workflows/publish-lib.yaml@main
with:
lib-name: "charms.sdcore_nrf.v0.fiveg_nrf"
lib-name: "charms.sdcore_nrf_k8s.v0.fiveg_nrf"
secrets: inherit
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 NRFProvides # type: ignore[import]
from charms.sdcore_nrf_k8s.v0.fiveg_nrf import NRFProvides # type: ignore[import]
from charms.tls_certificates_interface.v2.tls_certificates import ( # type: ignore[import]
CertificateAvailableEvent,
CertificateExpiringEvent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from ops.charm import CharmBase, RelationJoinedEvent
from ops.main import main

from lib.charms.sdcore_nrf.v0.fiveg_nrf import NRFProvides
from lib.charms.sdcore_nrf_k8s.v0.fiveg_nrf import NRFProvides


class DummyFiveGNRFProviderCharm(CharmBase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from ops.charm import CharmBase
from ops.main import main

from lib.charms.sdcore_nrf.v0.fiveg_nrf import NRFAvailableEvent, NRFBrokenEvent, NRFRequires
from lib.charms.sdcore_nrf_k8s.v0.fiveg_nrf import NRFAvailableEvent, NRFBrokenEvent, NRFRequires

logger = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def test_given_invalid_nrf_information_in_relation_data_when_relation_changed_th
relation_id=relation_id, app_or_unit=self.remote_app_name, key_values=relation_data
)
self.assertIn(
f"DEBUG:lib.charms.sdcore_nrf.v0.fiveg_nrf:Invalid relation data: {relation_data}",
f"DEBUG:lib.charms.sdcore_nrf_k8s.v0.fiveg_nrf:Invalid relation data: {relation_data}", # noqa: E501
log.output,
)

Expand Down Expand Up @@ -116,7 +116,7 @@ def test_given_nrf_information_not_in_relation_data_when_get_nrf_url_then_return
nrf_url = self.harness.charm.nrf_requirer.nrf_url
self.assertIsNone(nrf_url)
self.assertIn(
f"DEBUG:lib.charms.sdcore_nrf.v0.fiveg_nrf:Invalid relation data: {relation_data}",
f"DEBUG:lib.charms.sdcore_nrf_k8s.v0.fiveg_nrf:Invalid relation data: {relation_data}", # noqa: E501
log.output,
)

Expand All @@ -133,11 +133,11 @@ def test_given_nrf_information_in_relation_data_is_not_valid_when_get_nrf_url_th
nrf_url = self.harness.charm.nrf_requirer.nrf_url
self.assertIsNone(nrf_url)
self.assertIn(
f"DEBUG:lib.charms.sdcore_nrf.v0.fiveg_nrf:Invalid relation data: {relation_data}",
f"DEBUG:lib.charms.sdcore_nrf_k8s.v0.fiveg_nrf:Invalid relation data: {relation_data}", # noqa: E501
log.output,
)

@patch("lib.charms.sdcore_nrf.v0.fiveg_nrf.NRFRequirerCharmEvents.nrf_broken")
@patch("lib.charms.sdcore_nrf_k8s.v0.fiveg_nrf.NRFRequirerCharmEvents.nrf_broken")
def test_given_nrf_relation_created_when_relation_broken_then_nrf_broken_event_emitted(
self, patched_nrf_broken_event
):
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ envlist = lint, static, unit
src_path = {toxinidir}/src/
unit_test_path = {toxinidir}/tests/unit/
integration_test_path = {toxinidir}/tests/integration/
lib_path = {toxinidir}/lib/charms/sdcore_nrf/v0/
lib_path = {toxinidir}/lib/charms/sdcore_nrf_k8s/v0/
all_path = {[vars]src_path} {[vars]unit_test_path} {[vars]integration_test_path} {[vars]lib_path}

[testenv]
Expand Down

0 comments on commit ed7e984

Please sign in to comment.