Merge ~afreiberger/charm-grafana:blacken-20.10 into charm-grafana:master

Proposed by Drew Freiberger
Status: Merged
Approved by: Alvaro Uria
Approved revision: 8cb42f50c2153a23b468d35ed21292260044b7bd
Merged at revision: cd329fa7b3c3aad85bf6faf24209530d65786f18
Proposed branch: ~afreiberger/charm-grafana:blacken-20.10
Merge into: charm-grafana:master
Diff against target: 100 lines (+17/-22)
2 files modified
src/reactive/grafana.py (+3/-3)
src/tests/functional/tests/test_grafana.py (+14/-19)
Reviewer Review Type Date Requested Status
Alvaro Uria Approve
Review via email: mp+392348@code.launchpad.net

Commit message

blacken for 20.10 release

To post a comment you must log in.
Revision history for this message
Canonical IS Mergebot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Alvaro Uria (aluria) wrote :

lgtm

review: Approve
Revision history for this message
Canonical IS Mergebot (canonical-is-mergebot) wrote :

Change successfully merged at revision cd329fa7b3c3aad85bf6faf24209530d65786f18

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/reactive/grafana.py b/src/reactive/grafana.py
2index 3222c40..5c69eb9 100644
3--- a/src/reactive/grafana.py
4+++ b/src/reactive/grafana.py
5@@ -1164,18 +1164,18 @@ def ensure_dash_deserialized(dash):
6 def dashboards_joined(dashboards):
7 hookenv.log("hook %s triggered" % hookenv.hook_name(), "INFO")
8
9- remote_unit = os.environ.get('JUJU_REMOTE_UNIT', None)
10+ remote_unit = os.environ.get("JUJU_REMOTE_UNIT", None)
11 if not remote_unit:
12 hookenv.log("remote_unit is None, return", "WARNING")
13 return
14
15- dashboard_str = hookenv.relation_get('dashboard', remote_unit) # json str
16+ dashboard_str = hookenv.relation_get("dashboard", remote_unit) # json str
17 if not dashboard_str:
18 hookenv.log("dashboard field is empty, return", "WARNING")
19 return
20
21 dashboard = ensure_dash_deserialized(dashboard_str)
22- name = hookenv.relation_get('name', remote_unit) # dashboard name
23+ name = hookenv.relation_get("name", remote_unit) # dashboard name
24 remote_app = hookenv.remote_service_name()
25
26 success, reason = import_dashboard(dashboard, remote_app=remote_app, name=name)
27diff --git a/src/tests/functional/tests/test_grafana.py b/src/tests/functional/tests/test_grafana.py
28index 66caa81..83dc8ad 100644
29--- a/src/tests/functional/tests/test_grafana.py
30+++ b/src/tests/functional/tests/test_grafana.py
31@@ -81,30 +81,26 @@ class BaseGrafanaTest(unittest.TestCase):
32 time.sleep(65)
33 backupdir = model.run_on_unit(
34 self.lead_unit_name,
35- "ls {directory}".format(
36- directory=DEFAULT_BACKUP_DIRECTORY
37- )
38+ "ls {directory}".format(directory=DEFAULT_BACKUP_DIRECTORY),
39 )
40- self.assertTrue("No such file or directory" not in backupdir['Stderr'])
41+ self.assertTrue("No such file or directory" not in backupdir["Stderr"])
42 backups_start = model.run_on_unit(
43 self.lead_unit_name,
44 "ls {project}/{backup}".format(
45- project=DEFAULT_BACKUP_DIRECTORY,
46- backup=backupdir['Stdout'].strip()
47- )
48+ project=DEFAULT_BACKUP_DIRECTORY, backup=backupdir["Stdout"].strip()
49+ ),
50 )
51- self.assertTrue(".json" in backups_start['Stdout'])
52- number_of_backups_start = backups_start['Stdout'].count('.json')
53+ self.assertTrue(".json" in backups_start["Stdout"])
54+ number_of_backups_start = backups_start["Stdout"].count(".json")
55 self.assertTrue(number_of_backups_start >= 1)
56 time.sleep(65)
57 backups_end = model.run_on_unit(
58 self.lead_unit_name,
59 "ls {project}/{backup}".format(
60- project=DEFAULT_BACKUP_DIRECTORY,
61- backup=backupdir['Stdout'].strip()
62- )
63+ project=DEFAULT_BACKUP_DIRECTORY, backup=backupdir["Stdout"].strip()
64+ ),
65 )
66- number_of_backups_end = backups_end['Stdout'].count('.json')
67+ number_of_backups_end = backups_end["Stdout"].count(".json")
68 self.assertTrue(number_of_backups_end > number_of_backups_start)
69
70
71@@ -236,8 +232,8 @@ class CharmOperationTest(BaseGrafanaTest):
72 self.lead_unit_name,
73 "cat /etc/cron.d/juju-dashboards-backup",
74 )
75- self.assertTrue(DEFAULT_BACKUP_DIRECTORY in crontab['Stdout'])
76- self.assertTrue(DEFAULT_API_PORT in crontab['Stdout'])
77+ self.assertTrue(DEFAULT_BACKUP_DIRECTORY in crontab["Stdout"])
78+ self.assertTrue(DEFAULT_API_PORT in crontab["Stdout"])
79 self.verify_iterative_backups()
80
81 def test_14_grafana_dashboard_backup_port_change(self):
82@@ -247,16 +243,15 @@ class CharmOperationTest(BaseGrafanaTest):
83 self.application_name, {"dashboards_backup_schedule": "* * * * *"}
84 )
85 model.block_until_all_units_idle()
86- model.set_application_config(
87- self.application_name, {"port": port}
88- )
89+ model.set_application_config(self.application_name, {"port": port})
90 model.block_until_all_units_idle()
91 crontab = model.run_on_unit(
92 self.lead_unit_name, "cat /etc/cron.d/juju-dashboards-backup"
93 )
94- self.assertTrue(port in crontab['Stdout'])
95+ self.assertTrue(port in crontab["Stdout"])
96 self.verify_iterative_backups()
97
98+
99 class SnappedGrafanaTest(BaseGrafanaTest):
100 """Verify Grafana installed as a snap."""
101

Subscribers

People subscribed via source and target branches