mirror of
https://github.com/bendtherules/pytest_gui_status.git
synced 2026-08-18 13:42:26 +00:00
Move loading options from env code to utils
This commit is contained in:
@@ -7,13 +7,7 @@ from datetime import datetime
|
|||||||
import humanfriendly
|
import humanfriendly
|
||||||
import os.path
|
import os.path
|
||||||
from ..utils import s
|
from ..utils import s
|
||||||
|
from ..utils import REDIS_PORT
|
||||||
|
|
||||||
env_redis_port = os.environ.get("PYTEST_STATUS_PORT")
|
|
||||||
if env_redis_port:
|
|
||||||
REDIS_PORT = int(env_redis_port)
|
|
||||||
else:
|
|
||||||
REDIS_PORT = 5946
|
|
||||||
|
|
||||||
|
|
||||||
class Controller(htmlPy.Object):
|
class Controller(htmlPy.Object):
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ Done
|
|||||||
11. (---) Use travis ci + install redis there
|
11. (---) Use travis ci + install redis there
|
||||||
12. (---) Show gui only with option --status_gui
|
12. (---) Show gui only with option --status_gui
|
||||||
13. (---) env config for redis + test for that
|
13. (---) env config for redis + test for that
|
||||||
14. (---) Use redis_db fixture for travis debugging (---)
|
14. (---) Use redis_db fixture for travis debuggings
|
||||||
|
|
||||||
|
|
||||||
Think
|
Think
|
||||||
|
|||||||
@@ -7,23 +7,7 @@ import os
|
|||||||
import psutil
|
import psutil
|
||||||
import datetime
|
import datetime
|
||||||
from ..utils import s
|
from ..utils import s
|
||||||
|
from ..utils import REDIS_PORT, command_redis_server, command_status_gui_gen
|
||||||
|
|
||||||
env_redis_port = os.environ.get("PYTEST_STATUS_PORT")
|
|
||||||
if env_redis_port:
|
|
||||||
REDIS_PORT = int(env_redis_port)
|
|
||||||
else:
|
|
||||||
REDIS_PORT = 5946
|
|
||||||
|
|
||||||
REDIS_PATH = os.environ.get("REDIS_PATH") or "redis-server"
|
|
||||||
REDIS_ARGS = os.environ.get("REDIS_ARGS") or ""
|
|
||||||
|
|
||||||
command_redis_server_gen = "{REDIS_PATH} --port {REDIS_PORT} {REDIS_ARGS}"
|
|
||||||
command_redis_server = command_redis_server_gen.format(REDIS_PATH=REDIS_PATH,
|
|
||||||
REDIS_ARGS=REDIS_ARGS,
|
|
||||||
REDIS_PORT=REDIS_PORT)
|
|
||||||
|
|
||||||
command_status_gui_gen = "pytest_gui_status \"{norm_dir_name}\""
|
|
||||||
|
|
||||||
# Redis will look like:
|
# Redis will look like:
|
||||||
# PYTEST_STATUS_DB = 1
|
# PYTEST_STATUS_DB = 1
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
env_redis_port = os.environ.get("PYTEST_STATUS_PORT")
|
||||||
|
if env_redis_port:
|
||||||
|
REDIS_PORT = int(env_redis_port)
|
||||||
|
else:
|
||||||
|
REDIS_PORT = 5946
|
||||||
|
|
||||||
|
REDIS_PATH = os.environ.get("REDIS_PATH") or "redis-server"
|
||||||
|
REDIS_ARGS = os.environ.get("REDIS_ARGS") or ""
|
||||||
|
|
||||||
|
command_redis_server_gen = "{REDIS_PATH} --port {REDIS_PORT} {REDIS_ARGS}"
|
||||||
|
command_redis_server = command_redis_server_gen.format(REDIS_PATH=REDIS_PATH,
|
||||||
|
REDIS_ARGS=REDIS_ARGS,
|
||||||
|
REDIS_PORT=REDIS_PORT)
|
||||||
|
|
||||||
|
command_status_gui_gen = "pytest_gui_status \"{norm_dir_name}\""
|
||||||
|
|
||||||
|
|
||||||
def s(input_):
|
def s(input_):
|
||||||
''' Convert str or uncode or bytes to str.
|
''' Convert str or uncode or bytes to str.
|
||||||
If list, do it for all of them.
|
If list, do it for all of them.
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import pytest_gui_status.status_plugin.plugin as status_plugin
|
import pytest_gui_status.status_plugin.plugin as status_plugin
|
||||||
|
import pytest_gui_status.utils
|
||||||
|
|
||||||
from mock import patch, MagicMock
|
from mock import patch, MagicMock
|
||||||
import redis
|
import redis
|
||||||
@@ -6,7 +7,7 @@ import pytest
|
|||||||
|
|
||||||
from ..utils_test import reload_2_3
|
from ..utils_test import reload_2_3
|
||||||
|
|
||||||
REDIS_TEST_PORT = status_plugin.REDIS_PORT + 1
|
REDIS_TEST_PORT = pytest_gui_status.utils.REDIS_PORT + 1
|
||||||
|
|
||||||
mock_htmlPy_module = MagicMock()
|
mock_htmlPy_module = MagicMock()
|
||||||
mock_htmlPy_module.Object = object
|
mock_htmlPy_module.Object = object
|
||||||
@@ -43,6 +44,7 @@ def redis_master(request, auto_shutdown=True):
|
|||||||
def test_redis_fail_1(tmpdir):
|
def test_redis_fail_1(tmpdir):
|
||||||
# load new redis port
|
# load new redis port
|
||||||
import pytest_gui_status.status_gui.gui_backend as gui_backend
|
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(gui_backend)
|
||||||
reload_2_3(status_plugin)
|
reload_2_3(status_plugin)
|
||||||
|
|
||||||
@@ -71,6 +73,7 @@ def test_redis_fail_1(tmpdir):
|
|||||||
def test_redis_fail_2(tmpdir, redis_master):
|
def test_redis_fail_2(tmpdir, redis_master):
|
||||||
# load new redis port
|
# load new redis port
|
||||||
import pytest_gui_status.status_gui.gui_backend as gui_backend
|
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(gui_backend)
|
||||||
reload_2_3(status_plugin)
|
reload_2_3(status_plugin)
|
||||||
|
|
||||||
@@ -102,6 +105,7 @@ def test_redis_fail_2(tmpdir, redis_master):
|
|||||||
def test_redis_fail_3(tmpdir, redis_master):
|
def test_redis_fail_3(tmpdir, redis_master):
|
||||||
# load new redis port
|
# load new redis port
|
||||||
import pytest_gui_status.status_gui.gui_backend as gui_backend
|
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(gui_backend)
|
||||||
reload_2_3(status_plugin)
|
reload_2_3(status_plugin)
|
||||||
|
|
||||||
@@ -132,6 +136,7 @@ def test_redis_fail_3(tmpdir, redis_master):
|
|||||||
def test_redis_fail_4(tmpdir, redis_master):
|
def test_redis_fail_4(tmpdir, redis_master):
|
||||||
# load new redis port
|
# load new redis port
|
||||||
import pytest_gui_status.status_gui.gui_backend as gui_backend
|
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(gui_backend)
|
||||||
reload_2_3(status_plugin)
|
reload_2_3(status_plugin)
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,11 @@ def test_env_redis_1():
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
import pytest_gui_status.status_plugin.plugin
|
import pytest_gui_status.status_plugin.plugin
|
||||||
reload_2_3(pytest_gui_status.status_plugin.plugin)
|
import pytest_gui_status.utils
|
||||||
|
|
||||||
redis_cmd_final = pytest_gui_status.status_plugin.plugin.command_redis_server
|
reload_2_3(pytest_gui_status.utils)
|
||||||
|
reload_2_3(pytest_gui_status.status_plugin.plugin)
|
||||||
|
reload_2_3(status_plugin)
|
||||||
|
|
||||||
|
redis_cmd_final = status_plugin.command_redis_server
|
||||||
assert(redis_cmd_final == "test_redis --port 1234 --test_arg = test_val")
|
assert(redis_cmd_final == "test_redis --port 1234 --test_arg = test_val")
|
||||||
|
|||||||
Reference in New Issue
Block a user