From 42d4a2fae96b8b4ba35d3a88e20f278d79a0ccc6 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sun, 12 Jan 2014 23:01:59 +1300 Subject: Script refactoring: move script command parsing into script module. --- test/test_flow.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'test/test_flow.py') diff --git a/test/test_flow.py b/test/test_flow.py index bf6a7a42..680d59e5 100644 --- a/test/test_flow.py +++ b/test/test_flow.py @@ -563,12 +563,12 @@ class TestFlowMaster: def test_load_script(self): s = flow.State() fm = flow.FlowMaster(None, s) - assert not fm.load_script([tutils.test_data.path("scripts/a.py")]) - assert not fm.load_script([tutils.test_data.path("scripts/a.py")]) + assert not fm.load_script(tutils.test_data.path("scripts/a.py")) + assert not fm.load_script(tutils.test_data.path("scripts/a.py")) assert not fm.unload_script(fm.scripts[0]) assert not fm.unload_script(fm.scripts[0]) - assert fm.load_script(["nonexistent"]) - assert "ValueError" in fm.load_script([tutils.test_data.path("scripts/starterr.py")]) + assert fm.load_script("nonexistent") + assert "ValueError" in fm.load_script(tutils.test_data.path("scripts/starterr.py")) assert len(fm.scripts) == 0 def test_replay(self): @@ -584,7 +584,7 @@ class TestFlowMaster: def test_script_reqerr(self): s = flow.State() fm = flow.FlowMaster(None, s) - assert not fm.load_script([tutils.test_data.path("scripts/reqerr.py")]) + assert not fm.load_script(tutils.test_data.path("scripts/reqerr.py")) req = tutils.treq() fm.handle_clientconnect(req.client_conn) assert fm.handle_request(req) @@ -592,7 +592,7 @@ class TestFlowMaster: def test_script(self): s = flow.State() fm = flow.FlowMaster(None, s) - assert not fm.load_script([tutils.test_data.path("scripts/all.py")]) + assert not fm.load_script(tutils.test_data.path("scripts/all.py")) req = tutils.treq() fm.handle_clientconnect(req.client_conn) assert fm.scripts[0].ns["log"][-1] == "clientconnect" @@ -606,7 +606,7 @@ class TestFlowMaster: fm.handle_response(resp) assert fm.scripts[0].ns["log"][-1] == "response" #load second script - assert not fm.load_script([tutils.test_data.path("scripts/all.py")]) + assert not fm.load_script(tutils.test_data.path("scripts/all.py")) assert len(fm.scripts) == 2 dc = flow.ClientDisconnect(req.client_conn) dc.reply = controller.DummyReply() @@ -659,7 +659,7 @@ class TestFlowMaster: err.reply = controller.DummyReply() fm.handle_error(err) - fm.load_script([tutils.test_data.path("scripts/a.py")]) + fm.load_script(tutils.test_data.path("scripts/a.py")) fm.shutdown() def test_client_playback(self): -- cgit v1.2.3 From 069aca1df4223416bc76883c37078e9f2deef28f Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Mon, 13 Jan 2014 14:20:34 +1300 Subject: Deprecate Flow.unload_script in favor of Flow.unload_scripts In the presence of arguments, unloading a single script is clumsy and less useful. --- test/test_flow.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'test/test_flow.py') diff --git a/test/test_flow.py b/test/test_flow.py index 680d59e5..f9198f0c 100644 --- a/test/test_flow.py +++ b/test/test_flow.py @@ -565,8 +565,7 @@ class TestFlowMaster: fm = flow.FlowMaster(None, s) assert not fm.load_script(tutils.test_data.path("scripts/a.py")) assert not fm.load_script(tutils.test_data.path("scripts/a.py")) - assert not fm.unload_script(fm.scripts[0]) - assert not fm.unload_script(fm.scripts[0]) + assert not fm.unload_scripts() assert fm.load_script("nonexistent") assert "ValueError" in fm.load_script(tutils.test_data.path("scripts/starterr.py")) assert len(fm.scripts) == 0 @@ -613,9 +612,13 @@ class TestFlowMaster: fm.handle_clientdisconnect(dc) assert fm.scripts[0].ns["log"][-1] == "clientdisconnect" assert fm.scripts[1].ns["log"][-1] == "clientdisconnect" + + #unload first script - fm.unload_script(fm.scripts[0]) - assert len(fm.scripts) == 1 + fm.unload_scripts() + assert len(fm.scripts) == 0 + + assert not fm.load_script(tutils.test_data.path("scripts/all.py")) err = flow.Error(f.request, "msg") err.reply = controller.DummyReply() fm.handle_error(err) -- cgit v1.2.3