|
@@ -10,6 +10,7 @@
|
|
# specific language governing permissions and limitations under the License.
|
|
# specific language governing permissions and limitations under the License.
|
|
|
|
|
|
import json
|
|
import json
|
|
|
|
+from unittest.mock import patch
|
|
|
|
|
|
import pandas as pd
|
|
import pandas as pd
|
|
import pytest
|
|
import pytest
|
|
@@ -24,21 +25,24 @@ def test__get_real_var_name(gui: Gui):
|
|
assert res[0] == ""
|
|
assert res[0] == ""
|
|
assert res[1] == ""
|
|
assert res[1] == ""
|
|
|
|
|
|
- gui.run(run_server=False)
|
|
|
|
|
|
+ with patch("sys.argv", ["prog"]):
|
|
|
|
+ gui.run(run_server=False)
|
|
with gui.get_flask_app().app_context():
|
|
with gui.get_flask_app().app_context():
|
|
with pytest.raises(NameError):
|
|
with pytest.raises(NameError):
|
|
res = gui._get_real_var_name(f"{_TaipyContent.get_hash()}_var")
|
|
res = gui._get_real_var_name(f"{_TaipyContent.get_hash()}_var")
|
|
|
|
|
|
|
|
|
|
def test__get_user_instance(gui: Gui):
|
|
def test__get_user_instance(gui: Gui):
|
|
- gui.run(run_server=False)
|
|
|
|
|
|
+ with patch("sys.argv", ["prog"]):
|
|
|
|
+ gui.run(run_server=False)
|
|
with gui.get_flask_app().app_context():
|
|
with gui.get_flask_app().app_context():
|
|
with pytest.warns(UserWarning):
|
|
with pytest.warns(UserWarning):
|
|
gui._get_user_instance("", type(None))
|
|
gui._get_user_instance("", type(None))
|
|
|
|
|
|
|
|
|
|
def test__call_broadcast_callback(gui: Gui):
|
|
def test__call_broadcast_callback(gui: Gui):
|
|
- gui.run(run_server=False)
|
|
|
|
|
|
+ with patch("sys.argv", ["prog"]):
|
|
|
|
+ gui.run(run_server=False)
|
|
with gui.get_flask_app().app_context():
|
|
with gui.get_flask_app().app_context():
|
|
res = gui._call_broadcast_callback(lambda s, t: t, ["Hello World"], "mine")
|
|
res = gui._call_broadcast_callback(lambda s, t: t, ["Hello World"], "mine")
|
|
assert res == "Hello World"
|
|
assert res == "Hello World"
|
|
@@ -50,7 +54,8 @@ def test__call_broadcast_callback(gui: Gui):
|
|
|
|
|
|
|
|
|
|
def test__refresh_expr(gui: Gui):
|
|
def test__refresh_expr(gui: Gui):
|
|
- gui.run(run_server=False)
|
|
|
|
|
|
+ with patch("sys.argv", ["prog"]):
|
|
|
|
+ gui.run(run_server=False)
|
|
with gui.get_flask_app().app_context():
|
|
with gui.get_flask_app().app_context():
|
|
res = gui._refresh_expr("var", None)
|
|
res = gui._refresh_expr("var", None)
|
|
assert res is None
|
|
assert res is None
|
|
@@ -58,7 +63,8 @@ def test__refresh_expr(gui: Gui):
|
|
|
|
|
|
def test__tbl_cols(gui: Gui):
|
|
def test__tbl_cols(gui: Gui):
|
|
data = pd.DataFrame({"col1": [0, 1, 2], "col2": [True, True, False]})
|
|
data = pd.DataFrame({"col1": [0, 1, 2], "col2": [True, True, False]})
|
|
- gui.run(run_server=False)
|
|
|
|
|
|
+ with patch("sys.argv", ["prog"]):
|
|
|
|
+ gui.run(run_server=False)
|
|
with gui.get_flask_app().app_context():
|
|
with gui.get_flask_app().app_context():
|
|
res = gui._tbl_cols(True, None, json.dumps({}), json.dumps({"data": "data"}), data=data)
|
|
res = gui._tbl_cols(True, None, json.dumps({}), json.dumps({"data": "data"}), data=data)
|
|
d = json.loads(res)
|
|
d = json.loads(res)
|
|
@@ -71,7 +77,8 @@ def test__tbl_cols(gui: Gui):
|
|
|
|
|
|
def test__chart_conf(gui: Gui):
|
|
def test__chart_conf(gui: Gui):
|
|
data = pd.DataFrame({"col1": [0, 1, 2], "col2": [True, True, False]})
|
|
data = pd.DataFrame({"col1": [0, 1, 2], "col2": [True, True, False]})
|
|
- gui.run(run_server=False)
|
|
|
|
|
|
+ with patch("sys.argv", ["prog"]):
|
|
|
|
+ gui.run(run_server=False)
|
|
with gui.get_flask_app().app_context():
|
|
with gui.get_flask_app().app_context():
|
|
res = gui._chart_conf(True, None, json.dumps({}), json.dumps({"data": "data"}), data=data)
|
|
res = gui._chart_conf(True, None, json.dumps({}), json.dumps({"data": "data"}), data=data)
|
|
d = json.loads(res)
|
|
d = json.loads(res)
|
|
@@ -87,7 +94,8 @@ def test__chart_conf(gui: Gui):
|
|
|
|
|
|
|
|
|
|
def test__get_valid_adapter_result(gui: Gui):
|
|
def test__get_valid_adapter_result(gui: Gui):
|
|
- gui.run(run_server=False)
|
|
|
|
|
|
+ with patch("sys.argv", ["prog"]):
|
|
|
|
+ gui.run(run_server=False)
|
|
with gui.get_flask_app().app_context():
|
|
with gui.get_flask_app().app_context():
|
|
res = gui._get_valid_adapter_result(("id", "label"))
|
|
res = gui._get_valid_adapter_result(("id", "label"))
|
|
assert isinstance(res, tuple)
|
|
assert isinstance(res, tuple)
|