Skip to content

Commit

Permalink
fix failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
backmari committed Jan 7, 2025
1 parent 978f293 commit be6c462
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/webmon_app/reporting/tests/test_report/test_view_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,21 +319,19 @@ def test_get_plot_template_dict(self, mockGetDataFromServer):
rst = get_plot_template_dict(run, inst, run_id)
self.assertTrue("html_data" in rst.keys())

@mock.patch("httplib2.HTTPSConnectionWithTimeout")
def test_get_plot_data_from_server(self, mockHTTPSCon):
@mock.patch("requests.get")
def test_get_plot_data_from_server(self, mockRequestsGet):
from reporting.report.view_util import get_plot_data_from_server

# mock external dependencies
getresponse_return = mock.MagicMock()
getresponse_return.status = 200
getresponse_return.read = mock.MagicMock(return_value="test")
con_return = mock.MagicMock()
con_return.getresponse = mock.MagicMock(return_value=getresponse_return)
mockHTTPSCon.return_value = con_return
getresponse_return.status_code = 200
getresponse_return.text = "test"
mockRequestsGet.return_value = getresponse_return
# test
inst = Instrument.objects.get(name="test_instrument")
run = DataRun.objects.get(run_number=1, instrument_id=inst)
rst = get_plot_data_from_server(inst, run)
rst = get_plot_data_from_server(inst.name, run)
self.assertEqual(rst, "test")

def test_extract_d3_data_from_json(self):
Expand Down

0 comments on commit be6c462

Please sign in to comment.