diff --git a/aplt/tests/__init__.py b/aplt/tests/__init__.py index 35f7b6a..632b6f7 100644 --- a/aplt/tests/__init__.py +++ b/aplt/tests/__init__.py @@ -8,6 +8,9 @@ from twisted.trial import unittest +AUTOPUSH_SERVER = "wss://autopush.dev.mozaws.net/" + + def _wait_multiple(): from aplt.commands import wait yield wait(0.1) @@ -45,7 +48,7 @@ def tearDown(self): def test_basic_runner(self): import aplt.runner as runner h = runner.run_scenario({ - "WEBSOCKET_URL": "wss://autopush.dev.mozaws.net/", + "WEBSOCKET_URL": AUTOPUSH_SERVER, "SCENARIO_FUNCTION": "aplt.scenarios:basic", "SCENARIO_ARGS": [], }, run=False) @@ -60,7 +63,7 @@ def test_basic_with_vapid(self): "sub": "mailto:admin@example.com", "exp": int(time.time()) + 86400} h = runner.run_scenario({ - "WEBSOCKET_URL": "wss://autopush.dev.mozaws.net/", + "WEBSOCKET_URL": AUTOPUSH_SERVER, "SCENARIO_FUNCTION": "aplt.scenarios:basic", "SCENARIO_ARGS": [{"vapid_private_key": T_PRIVATE, "vapid_claims": claims}], @@ -90,7 +93,7 @@ def test_basic_with_vapid_str_args(self): "vapid_claims": claims} jclaims = json.dumps(args).replace(",", "\\,") h = runner.run_scenario({ - "WEBSOCKET_URL": "wss://autopush.dev.mozaws.net/", + "WEBSOCKET_URL": AUTOPUSH_SERVER, "SCENARIO_FUNCTION": "aplt.scenarios:basic", "SCENARIO_ARGS": [jclaims], }, run=False) @@ -101,7 +104,7 @@ def test_basic_with_vapid_str_args(self): def test_basic_testplan(self): import aplt.runner as runner lh = runner.run_testplan({ - "WEBSOCKET_URL": "wss://autopush.dev.mozaws.net/", + "WEBSOCKET_URL": AUTOPUSH_SERVER, "TEST_PLAN": "aplt.scenarios:basic, 5, 5, 0", }, run=False) d = Deferred() @@ -111,7 +114,7 @@ def test_basic_testplan(self): def test_spawn_testplan(self): import aplt.runner as runner h = runner.run_scenario({ - "WEBSOCKET_URL": "wss://autopush.dev.mozaws.net/", + "WEBSOCKET_URL": AUTOPUSH_SERVER, "SCENARIO_FUNCTION": "aplt.scenarios:_test_spawn", "SCENARIO_ARGS": [], }, run=False) @@ -122,7 +125,7 @@ def test_spawn_testplan(self): def test_spawn_multiple_testplan(self): import aplt.runner as runner h = runner.run_scenario({ - "WEBSOCKET_URL": "wss://autopush.dev.mozaws.net/", + "WEBSOCKET_URL": AUTOPUSH_SERVER, "SCENARIO_FUNCTION": "aplt.scenarios:_test_multiple_spawn", "SCENARIO_ARGS": [], }, run=False) @@ -133,7 +136,7 @@ def test_spawn_multiple_testplan(self): def test_basic_testplan_with_args(self): import aplt.runner as runner lh = runner.run_testplan({ - "WEBSOCKET_URL": "wss://autopush.dev.mozaws.net/", + "WEBSOCKET_URL": AUTOPUSH_SERVER, "TEST_PLAN": "aplt.scenarios:notification_forever, 5, 5, 0, 1, 1", }, run=False) d = Deferred() @@ -143,7 +146,7 @@ def test_basic_testplan_with_args(self): def test_basic_testplan_with_vapid(self): import aplt.runner as runner lh = runner.run_testplan({ - "WEBSOCKET_URL": "wss://autopush.dev.mozaws.net/", + "WEBSOCKET_URL": AUTOPUSH_SERVER, "TEST_PLAN": "aplt.scenarios:notification_forever, 5, 5, 0, 1, 1", "SCENARIO_KWARGS": {'vapid_claims': { @@ -158,7 +161,7 @@ def test_basic_testplan_with_vapid(self): def test_wait_twice(self): import aplt.runner as runner lh = runner.run_testplan({ - "WEBSOCKET_URL": "wss://autopush.dev.mozaws.net/", + "WEBSOCKET_URL": AUTOPUSH_SERVER, "TEST_PLAN": "aplt.tests:_wait_multiple, 1, 1, 0", }, run=False) d = Deferred() @@ -168,7 +171,7 @@ def test_wait_twice(self): def test_stack_gens(self): import aplt.runner as runner lh = runner.run_testplan({ - "WEBSOCKET_URL": "wss://autopush.dev.mozaws.net/", + "WEBSOCKET_URL": AUTOPUSH_SERVER, "TEST_PLAN": "aplt.tests:_stack_gens, 1, 1, 0", }, run=False) d = Deferred() @@ -178,7 +181,7 @@ def test_stack_gens(self): def test_class_method(self): import aplt.runner as runner lh = runner.run_testplan({ - "WEBSOCKET_URL": "wss://autopush.dev.mozaws.net/", + "WEBSOCKET_URL": AUTOPUSH_SERVER, "TEST_PLAN": "aplt.tests:Aclass.amethod, 1, 1, 0", }, run=False) d = Deferred() @@ -189,7 +192,7 @@ def test_class_method(self): def test_bad_testplan(self): import aplt.runner as runner runner.run_testplan({ - "WEBSOCKET_URL": "wss://autopush.dev.mozaws.net/", + "WEBSOCKET_URL": AUTOPUSH_SERVER, "TEST_PLAN": "aplt.scenarios:basic, 5, 5", }, run=False) @@ -197,7 +200,7 @@ def test_bad_testplan(self): def test_bad_load(self): import aplt.runner as runner runner.run_scenario({ - "WEBSOCKET_URL": "wss://autopush.dev.mozaws.net/", + "WEBSOCKET_URL": AUTOPUSH_SERVER, "SCENARIO_FUNCTION": "aplt.scenaribasic", "SCENARIO_ARGS": "", }, run=False) @@ -205,7 +208,7 @@ def test_bad_load(self): def test_notification_forever(self): import aplt.runner as runner h = runner.run_scenario({ - "WEBSOCKET_URL": "wss://autopush.dev.mozaws.net/", + "WEBSOCKET_URL": AUTOPUSH_SERVER, "SCENARIO_FUNCTION": "aplt.scenarios:notification_forever", "SCENARIO_ARGS": ["0", "1"], }, run=False) @@ -216,7 +219,7 @@ def test_notification_forever(self): def test_reconnect_forever(self): import aplt.runner as runner h = runner.run_scenario({ - "WEBSOCKET_URL": "wss://autopush.dev.mozaws.net/", + "WEBSOCKET_URL": AUTOPUSH_SERVER, "SCENARIO_FUNCTION": "aplt.scenarios:reconnect_forever", "SCENARIO_ARGS": ["0", "1"], }, run=False) @@ -227,7 +230,7 @@ def test_reconnect_forever(self): def test_expect_notifications(self): import aplt.runner as runner h = runner.run_scenario({ - "WEBSOCKET_URL": "wss://autopush.dev.mozaws.net/", + "WEBSOCKET_URL": AUTOPUSH_SERVER, "SCENARIO_FUNCTION": "aplt.scenarios:_expect_notifications", "SCENARIO_ARGS": [], }, run=False) @@ -240,7 +243,7 @@ def test_exception_restart(self): import aplt.scenarios as scenarios scenarios._RESTARTS = 0 h = runner.run_scenario({ - "WEBSOCKET_URL": "wss://autopush.dev.mozaws.net/", + "WEBSOCKET_URL": AUTOPUSH_SERVER, "SCENARIO_FUNCTION": "aplt.scenarios:_explode", "SCENARIO_ARGS": [], }, run=False) @@ -262,8 +265,7 @@ def _make_harness(self): from aplt.runner import RunnerHarness, parse_statsd_args from aplt.scenarios import basic client = parse_statsd_args({}) - self.rh = RunnerHarness(Mock(), "wss://autopush.dev.mozaws.net/", - basic, client) + self.rh = RunnerHarness(Mock(), AUTOPUSH_SERVER, basic, client) self.rh.metrics = client return self.rh