Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Commit

Permalink
fix: use a global variable to ease debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
pjenvey committed Nov 22, 2016
1 parent 7d5c1fd commit 8e0dc57
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions aplt/tests/__init__.py
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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}],
Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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()
Expand All @@ -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': {
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -189,23 +192,23 @@ 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)

@raises(Exception)
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)

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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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

Expand Down

0 comments on commit 8e0dc57

Please sign in to comment.