mirror of
https://github.com/bendtherules/pytest_gui_status.git
synced 2026-08-18 13:42:26 +00:00
@nd redis_state test with pass/fail + empty collect fix in plugin
This commit is contained in:
@@ -111,7 +111,8 @@ class Helpers(object):
|
|||||||
hash_dir_name = s(redis_db.hget("directories_to_hash", dir_name))
|
hash_dir_name = s(redis_db.hget("directories_to_hash", dir_name))
|
||||||
assert hash_dir_name is not None
|
assert hash_dir_name is not None
|
||||||
|
|
||||||
redis_db.rpush("{hash_a}_collect".format(hash_a=hash_dir_name), *list_test_name)
|
if list_test_name:
|
||||||
|
redis_db.rpush("{hash_a}_collect".format(hash_a=hash_dir_name), *list_test_name)
|
||||||
|
|
||||||
# set last updated
|
# set last updated
|
||||||
Helpers.modify_last_updated(dir_name)
|
Helpers.modify_last_updated(dir_name)
|
||||||
|
|||||||
@@ -17,6 +17,13 @@ mock_htmlPy_module.Object = object
|
|||||||
mock_htmlPy_module.Slot.return_value = (lambda func: func)
|
mock_htmlPy_module.Slot.return_value = (lambda func: func)
|
||||||
|
|
||||||
|
|
||||||
|
class MockTestResult(object):
|
||||||
|
def __init__(self, nodeid, outcome):
|
||||||
|
assert outcome in ["passed", "failed", "skipped"]
|
||||||
|
self.nodeid = nodeid
|
||||||
|
self.outcome = outcome
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
def redis_master(request, auto_shutdown=True):
|
def redis_master(request, auto_shutdown=True):
|
||||||
import pytest_gui_status.status_plugin.plugin as status_plugin
|
import pytest_gui_status.status_plugin.plugin as status_plugin
|
||||||
@@ -192,3 +199,42 @@ class TestBackendState(object):
|
|||||||
assert tmp_controller.last_state["pass"] == []
|
assert tmp_controller.last_state["pass"] == []
|
||||||
assert tmp_controller.last_state["fail"] == []
|
assert tmp_controller.last_state["fail"] == []
|
||||||
assert tmp_controller.last_state["skip"] == []
|
assert tmp_controller.last_state["skip"] == []
|
||||||
|
|
||||||
|
@patch("pytest_gui_status.status_gui.utils_gui.render_template", MagicMock())
|
||||||
|
def test_backend_state_2(self, tmpdir, redis_master):
|
||||||
|
# load new redis port
|
||||||
|
import pytest_gui_status.status_gui.gui_backend as gui_backend
|
||||||
|
reload_2_3(pytest_gui_status.utils)
|
||||||
|
reload_2_3(gui_backend)
|
||||||
|
reload_2_3(status_plugin)
|
||||||
|
|
||||||
|
# start Redis
|
||||||
|
redis_master.init(tmpdir.strpath)
|
||||||
|
|
||||||
|
# setup state
|
||||||
|
status_plugin.Helpers.on_collectstart(tmpdir.strpath)
|
||||||
|
status_plugin.Helpers.on_collectend(tmpdir.strpath, [])
|
||||||
|
status_plugin.Helpers.on_test_eachstart(tmpdir.strpath)
|
||||||
|
status_plugin.Helpers.on_test_eachend(tmpdir.strpath, [
|
||||||
|
MockTestResult("pass_1", "passed"),
|
||||||
|
MockTestResult("fail_1", "failed"),
|
||||||
|
MockTestResult("pass_2", "passed"),
|
||||||
|
MockTestResult("skip_1", "skipped"),
|
||||||
|
])
|
||||||
|
|
||||||
|
# mock app_gui with path
|
||||||
|
fake_app_gui = MagicMock()
|
||||||
|
fake_app_gui.dir_name = tmpdir.strpath
|
||||||
|
|
||||||
|
tmp_controller = gui_backend.Controller(fake_app_gui)
|
||||||
|
tmp_controller.redraw()
|
||||||
|
|
||||||
|
assert tmp_controller.last_state["dir_name"] == tmpdir.strpath
|
||||||
|
assert tmp_controller.last_state["dir_name_topfolder"] ==\
|
||||||
|
os.path.basename(tmpdir.strpath)
|
||||||
|
assert tmp_controller.last_state["state"] == "runtest"
|
||||||
|
assert tmp_controller.last_state["last_updated_obj"] <= datetime.datetime.now()
|
||||||
|
assert tmp_controller.last_state["collect"] == []
|
||||||
|
assert sorted(tmp_controller.last_state["pass"]) == sorted(["pass_1", "pass_2"])
|
||||||
|
assert tmp_controller.last_state["fail"] == ["fail_1"]
|
||||||
|
assert tmp_controller.last_state["skip"] == ["skip_1"]
|
||||||
|
|||||||
Reference in New Issue
Block a user