diff --git a/src/webmon_app/reporting/report/view_util.py b/src/webmon_app/reporting/report/view_util.py index f09d7b95..3a4c4816 100644 --- a/src/webmon_app/reporting/report/view_util.py +++ b/src/webmon_app/reporting/report/view_util.py @@ -10,8 +10,8 @@ import datetime import string import re -import requests import hashlib +import requests from reporting.report.models import ( DataRun, RunStatus, @@ -510,11 +510,12 @@ def get_plot_template_dict(run_object=None, instrument=None, run_id=None): "plot_label_x": "", "plot_label_y": "", "update_url": None, + "key": generate_key(instrument, run_id), } url_template = string.Template(settings.LIVE_DATA_SERVER) live_data_url = url_template.substitute(instrument=instrument, run_number=run_id) - live_data_url = "https://%s:%s%s" % ( + live_data_url = "https://{}:{}{}".format( settings.LIVE_DATA_SERVER_DOMAIN, settings.LIVE_DATA_SERVER_PORT, live_data_url, @@ -524,7 +525,7 @@ def get_plot_template_dict(run_object=None, instrument=None, run_id=None): html_data = get_plot_data_from_server(instrument, run_id, "html") if html_data is not None: plot_dict["html_data"] = html_data - plot_dict["update_url"] = append_key("%s/html/" % live_data_url, instrument, run_id) + plot_dict["update_url"] = append_key(live_data_url + "/html/", instrument, run_id) if extract_ascii_from_div(html_data) is not None: plot_dict["data_url"] = reverse("report:download_reduced_data", args=[instrument, run_id]) return plot_dict @@ -534,7 +535,7 @@ def get_plot_template_dict(run_object=None, instrument=None, run_id=None): # Third, local json data for the d3 plots if json_data: - plot_dict["update_url"] = append_key("%s/json/" % live_data_url, instrument, run_id) + plot_dict["update_url"] = append_key(live_data_url + "/json/", instrument, run_id) plot_data, x_label, y_label = extract_d3_data_from_json(json_data) if plot_data is not None: diff --git a/src/webmon_app/reporting/tests/test_report/test_view_util.py b/src/webmon_app/reporting/tests/test_report/test_view_util.py index e6863efd..4ada513e 100644 --- a/src/webmon_app/reporting/tests/test_report/test_view_util.py +++ b/src/webmon_app/reporting/tests/test_report/test_view_util.py @@ -11,12 +11,7 @@ from reporting.report.models import WorkflowSummary from reporting.report.models import StatusQueueMessageCount -import os import json -from reporting import dasmon, report, reporting_app -import httplib2 - -_ = [dasmon, report, reporting_app, os, httplib2] class ViewUtilTest(TestCase): diff --git a/tests/test_livedata.py b/tests/test_livedata.py index 894b3a4e..dbff088b 100644 --- a/tests/test_livedata.py +++ b/tests/test_livedata.py @@ -61,9 +61,9 @@ def send_request(self, task, run_number, requestType): return response.text def test_reduction_request_livedata(self): - key = generate_key(self.instrument, self.run_number) ssl_crt_filename = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../nginx/nginx.crt") + key = generate_key(self.instrument, self.run_number) # first check that the there isn't an existing plot, should 404 response = requests.get( f"{LIVEDATA_TEST_URL}/plots/{self.instrument}/{self.run_number}/update/html/?key={key}",