diff --git a/locust/main.py b/locust/main.py index dbaf737bf3..148d2b78aa 100644 --- a/locust/main.py +++ b/locust/main.py @@ -178,9 +178,6 @@ def is_valid_percentile(parameter): sys.stderr.write("[DEPRECATED] The --hatch-rate parameter has been renamed --spawn-rate\n") options.spawn_rate = options.hatch_rate - if options.legacy_ui: - sys.stderr.write("[DEPRECATED] The legacy UI is deprecated and will be removed soon\n") - # setup logging if not options.skip_log_setup: if options.loglevel.upper() in ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]: diff --git a/locust/test/test_fasthttp.py b/locust/test/test_fasthttp.py index f71ae73435..d257fe4e31 100644 --- a/locust/test/test_fasthttp.py +++ b/locust/test/test_fasthttp.py @@ -11,6 +11,7 @@ import gevent from geventhttpclient.client import HTTPClientPool +from pyquery import PyQuery as pq from .testcases import LocustTestCase, WebserverTestCase from .util import create_tls_cert @@ -777,7 +778,8 @@ def tearDown(self): def test_ssl_request_insecure(self): s = FastHttpSession(self.environment, "https://127.0.0.1:%i" % self.web_port, insecure=True, user=None) - r = s.get("/") - self.assertEqual(200, r.status_code) - self.assertIn("
Script: None
", r.text) + response = s.get("/") + d = pq(response.content.decode("utf-8")) + + self.assertEqual(200, response.status_code) + self.assertIn('"users": null', str(d)) diff --git a/locust/test/test_main.py b/locust/test/test_main.py index ecce05f07a..2e6d6e8197 100644 --- a/locust/test/test_main.py +++ b/locust/test/test_main.py @@ -1136,18 +1136,9 @@ def test_html_report_option(self): with open(html_report_file_path, encoding="utf-8") as f: html_report_content = f.read() - # make sure title appears in the report _, locustfile = os.path.split(mocked.file_path) - self.assertIn(f"Script: {locustfile}
", html_report_content) - - # make sure host appears in the report - self.assertIn("https://test.com/", html_report_content) - - # make sure the charts container appears in the report - self.assertIn("charts-container", html_report_content) - - self.assertNotIn("Download the Report", html_report_content, "Download report link found in HTML content") + self.assertIn('"host": "https://test.com/"', html_report_content) + self.assertIn('"show_download_link": false', html_report_content) def test_run_with_userclass_picker(self): with temporary_file(content=MOCK_LOCUSTFILE_CONTENT_A) as file1: diff --git a/locust/test/test_web.py b/locust/test/test_web.py index e8c904be23..d317c603b8 100644 --- a/locust/test/test_web.py +++ b/locust/test/test_web.py @@ -105,11 +105,11 @@ def test_index(self): def test_index_with_spawn_options(self): html_to_option = { - "user_count": ["-u", "100"], + "num_users": ["-u", "100"], "spawn_rate": ["-r", "10.0"], } + for html_name_to_test in html_to_option.keys(): - # Test that setting each spawn option individually populates the corresponding field in the html, and none of the others self.environment.parsed_options = parse_options(html_to_option[html_name_to_test]) response = requests.get("http://127.0.0.1:%i/" % self.web_port) @@ -117,15 +117,7 @@ def test_index_with_spawn_options(self): d = pq(response.content.decode("utf-8")) - for html_name in html_to_option.keys(): - start_value = d(f".start [name={html_name}]").attr("value") - edit_value = d(f".edit [name={html_name}]").attr("value") - if html_name_to_test == html_name: - self.assertEqual(html_to_option[html_name][1], start_value) - self.assertEqual(html_to_option[html_name][1], edit_value) - else: - self.assertEqual("1", start_value, msg=f"start value was {start_value} for {html_name}") - self.assertEqual("1", edit_value, msg=f"edit value was {edit_value} for {html_name}") + self.assertIn(f'"{html_name_to_test}": {html_to_option[html_name_to_test][1]}', str(d)) def test_stats_no_data(self): self.assertEqual(200, requests.get("http://127.0.0.1:%i/stats/requests" % self.web_port).status_code) @@ -944,40 +936,42 @@ class MyUser2(User): response = requests.get("http://127.0.0.1:%i/" % self.web_port) self.assertEqual(200, response.status_code) self.assertNotIn("http://example.com", response.content.decode("utf-8")) - self.assertIn("setting this will override the host on all User classes", response.content.decode("utf-8")) def test_report_page(self): self.stats.log_request("GET", "/test", 120, 5612) r = requests.get("http://127.0.0.1:%i/stats/report" % self.web_port) + + d = pq(r.content.decode("utf-8")) + self.assertEqual(200, r.status_code) - self.assertIn("Script: None
", r.text) - self.assertIn("charts-container", r.text) - self.assertIn( - 'Download the Report', - r.text, - "Download report link not found in HTML content", - ) + self.assertIn('"host": "None"', str(d)) + self.assertIn('"num_requests": 1', str(d)) + self.assertIn('"is_report": true', str(d)) + self.assertIn('"show_download_link": true', str(d)) def test_report_page_empty_stats(self): r = requests.get("http://127.0.0.1:%i/stats/report" % self.web_port) self.assertEqual(200, r.status_code) - self.assertIn("