-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tag with charm name to dashboard (#390)
* Add tag with charm name to dashboard * Bump LIBPATCH * Update base64lzma string
- Loading branch information
Showing
3 changed files
with
52 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import unittest | ||
from charms.grafana_k8s.v0.grafana_dashboard import CharmedDashboard | ||
|
||
|
||
class CharmedDashboardTest(unittest.TestCase): | ||
def test_add_tags_to_dashboard_without_tags(self): | ||
# GIVEN a dashboard dict with no tags | ||
dashboard = {} | ||
|
||
# WHEN tags are added | ||
CharmedDashboard._add_tags(dashboard, "my-charm") | ||
|
||
# THEN list of tags only contains MyCharm | ||
self.assertListEqual(dashboard["tags"], ["charm: my-charm"]) | ||
|
||
def test_add_tags_to_dashboard_with_tags(self): | ||
# GIVEN a dashboard dict with some tags | ||
dashboard = {"tags": ["one", "two"]} | ||
|
||
# WHEN tags are added | ||
CharmedDashboard._add_tags(dashboard, "my-charm") | ||
|
||
# THEN list of tags is extended with MyCharm | ||
self.assertListEqual(dashboard["tags"], ["one", "two", "charm: my-charm"]) | ||
|
||
def test_add_tags_to_dashboard_with_charm_tag(self): | ||
# GIVEN a dashboard dict with a tag that starts with "charm: " | ||
dashboard = {"tags": ["charm: something-else"]} | ||
|
||
# WHEN tags are added | ||
CharmedDashboard._add_tags(dashboard, "my-charm") | ||
|
||
# THEN list of tags is unaffected | ||
self.assertListEqual(dashboard["tags"], ["charm: something-else"]) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters