Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
sed-i committed Dec 20, 2024
1 parent 27f9eb0 commit 7066173
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/cosl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""Utils for observability Juju charms."""

from .cos_tool import CosTool
from .grafana_dashboard import GrafanaDashboard, LZMABase64, DashboardPath40UID
from .grafana_dashboard import DashboardPath40UID, GrafanaDashboard, LZMABase64
from .juju_topology import JujuTopology
from .mandatory_relation_pairs import MandatoryRelationPairs
from .rules import AlertRules, RecordingRules
Expand Down
5 changes: 2 additions & 3 deletions src/cosl/grafana_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import logging
import lzma
import warnings
from typing import Any, Dict, Tuple, Union, ClassVar
from typing import Any, ClassVar, Dict, Tuple, Union

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -66,6 +66,7 @@ def decompress(cls, compressed: str) -> str:


class DashboardPath40UID:
"""A helper class for dashboard UID of length 40, generated from charm name and dashboard path."""

length: ClassVar[int] = 40

Expand Down Expand Up @@ -114,5 +115,3 @@ def is_valid(cls, uid: str) -> bool:
except binascii.Error:
return False
return True


8 changes: 6 additions & 2 deletions tests/test_grafana_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import json
import unittest

from cosl import GrafanaDashboard, LZMABase64, DashboardPath40UID
from cosl import DashboardPath40UID, GrafanaDashboard, LZMABase64


class TestRoundTripEncDec(unittest.TestCase):
Expand Down Expand Up @@ -52,4 +52,8 @@ def test_validity(self):
self.assertFalse(DashboardPath40UID.is_valid("non-hex string, crafted to be 40 chars!!"))

self.assertTrue(DashboardPath40UID.is_valid("0" * 40))
self.assertTrue(DashboardPath40UID.is_valid(DashboardPath40UID.generate("some-charm", "dashboard.json")))
self.assertTrue(
DashboardPath40UID.is_valid(
DashboardPath40UID.generate("some-charm", "dashboard.json")
)
)

0 comments on commit 7066173

Please sign in to comment.