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
diff --git a/src/reactive/grafana.py b/src/reactive/grafana.py
index 3222c40..5c69eb9 100644
--- a/src/reactive/grafana.py
+++ b/src/reactive/grafana.py
@@ -1164,18 +1164,18 @@ def ensure_dash_deserialized(dash):
1164def dashboards_joined(dashboards):1164def dashboards_joined(dashboards):
1165 hookenv.log("hook %s triggered" % hookenv.hook_name(), "INFO")1165 hookenv.log("hook %s triggered" % hookenv.hook_name(), "INFO")
11661166
1167 remote_unit = os.environ.get('JUJU_REMOTE_UNIT', None)1167 remote_unit = os.environ.get("JUJU_REMOTE_UNIT", None)
1168 if not remote_unit:1168 if not remote_unit:
1169 hookenv.log("remote_unit is None, return", "WARNING")1169 hookenv.log("remote_unit is None, return", "WARNING")
1170 return1170 return
11711171
1172 dashboard_str = hookenv.relation_get('dashboard', remote_unit) # json str1172 dashboard_str = hookenv.relation_get("dashboard", remote_unit) # json str
1173 if not dashboard_str:1173 if not dashboard_str:
1174 hookenv.log("dashboard field is empty, return", "WARNING")1174 hookenv.log("dashboard field is empty, return", "WARNING")
1175 return1175 return
11761176
1177 dashboard = ensure_dash_deserialized(dashboard_str)1177 dashboard = ensure_dash_deserialized(dashboard_str)
1178 name = hookenv.relation_get('name', remote_unit) # dashboard name1178 name = hookenv.relation_get("name", remote_unit) # dashboard name
1179 remote_app = hookenv.remote_service_name()1179 remote_app = hookenv.remote_service_name()
11801180
1181 success, reason = import_dashboard(dashboard, remote_app=remote_app, name=name)1181 success, reason = import_dashboard(dashboard, remote_app=remote_app, name=name)
diff --git a/src/tests/functional/tests/test_grafana.py b/src/tests/functional/tests/test_grafana.py
index 66caa81..83dc8ad 100644
--- a/src/tests/functional/tests/test_grafana.py
+++ b/src/tests/functional/tests/test_grafana.py
@@ -81,30 +81,26 @@ class BaseGrafanaTest(unittest.TestCase):
81 time.sleep(65)81 time.sleep(65)
82 backupdir = model.run_on_unit(82 backupdir = model.run_on_unit(
83 self.lead_unit_name,83 self.lead_unit_name,
84 "ls {directory}".format(84 "ls {directory}".format(directory=DEFAULT_BACKUP_DIRECTORY),
85 directory=DEFAULT_BACKUP_DIRECTORY
86 )
87 )85 )
88 self.assertTrue("No such file or directory" not in backupdir['Stderr'])86 self.assertTrue("No such file or directory" not in backupdir["Stderr"])
89 backups_start = model.run_on_unit(87 backups_start = model.run_on_unit(
90 self.lead_unit_name,88 self.lead_unit_name,
91 "ls {project}/{backup}".format(89 "ls {project}/{backup}".format(
92 project=DEFAULT_BACKUP_DIRECTORY,90 project=DEFAULT_BACKUP_DIRECTORY, backup=backupdir["Stdout"].strip()
93 backup=backupdir['Stdout'].strip()91 ),
94 )
95 )92 )
96 self.assertTrue(".json" in backups_start['Stdout'])93 self.assertTrue(".json" in backups_start["Stdout"])
97 number_of_backups_start = backups_start['Stdout'].count('.json')94 number_of_backups_start = backups_start["Stdout"].count(".json")
98 self.assertTrue(number_of_backups_start >= 1)95 self.assertTrue(number_of_backups_start >= 1)
99 time.sleep(65)96 time.sleep(65)
100 backups_end = model.run_on_unit(97 backups_end = model.run_on_unit(
101 self.lead_unit_name,98 self.lead_unit_name,
102 "ls {project}/{backup}".format(99 "ls {project}/{backup}".format(
103 project=DEFAULT_BACKUP_DIRECTORY,100 project=DEFAULT_BACKUP_DIRECTORY, backup=backupdir["Stdout"].strip()
104 backup=backupdir['Stdout'].strip()101 ),
105 )
106 )102 )
107 number_of_backups_end = backups_end['Stdout'].count('.json')103 number_of_backups_end = backups_end["Stdout"].count(".json")
108 self.assertTrue(number_of_backups_end > number_of_backups_start)104 self.assertTrue(number_of_backups_end > number_of_backups_start)
109105
110106
@@ -236,8 +232,8 @@ class CharmOperationTest(BaseGrafanaTest):
236 self.lead_unit_name,232 self.lead_unit_name,
237 "cat /etc/cron.d/juju-dashboards-backup",233 "cat /etc/cron.d/juju-dashboards-backup",
238 )234 )
239 self.assertTrue(DEFAULT_BACKUP_DIRECTORY in crontab['Stdout'])235 self.assertTrue(DEFAULT_BACKUP_DIRECTORY in crontab["Stdout"])
240 self.assertTrue(DEFAULT_API_PORT in crontab['Stdout'])236 self.assertTrue(DEFAULT_API_PORT in crontab["Stdout"])
241 self.verify_iterative_backups()237 self.verify_iterative_backups()
242238
243 def test_14_grafana_dashboard_backup_port_change(self):239 def test_14_grafana_dashboard_backup_port_change(self):
@@ -247,16 +243,15 @@ class CharmOperationTest(BaseGrafanaTest):
247 self.application_name, {"dashboards_backup_schedule": "* * * * *"}243 self.application_name, {"dashboards_backup_schedule": "* * * * *"}
248 )244 )
249 model.block_until_all_units_idle()245 model.block_until_all_units_idle()
250 model.set_application_config(246 model.set_application_config(self.application_name, {"port": port})
251 self.application_name, {"port": port}
252 )
253 model.block_until_all_units_idle()247 model.block_until_all_units_idle()
254 crontab = model.run_on_unit(248 crontab = model.run_on_unit(
255 self.lead_unit_name, "cat /etc/cron.d/juju-dashboards-backup"249 self.lead_unit_name, "cat /etc/cron.d/juju-dashboards-backup"
256 )250 )
257 self.assertTrue(port in crontab['Stdout'])251 self.assertTrue(port in crontab["Stdout"])
258 self.verify_iterative_backups()252 self.verify_iterative_backups()
259253
254
260class SnappedGrafanaTest(BaseGrafanaTest):255class SnappedGrafanaTest(BaseGrafanaTest):
261 """Verify Grafana installed as a snap."""256 """Verify Grafana installed as a snap."""
262257

Subscribers

People subscribed via source and target branches