mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 16:43:06 +00:00
refactor: move ui deployment to it's own file
This commit is contained in:
@@ -31,7 +31,7 @@ from freqtrade.commands import (
|
||||
start_webserver,
|
||||
)
|
||||
from freqtrade.commands.db_commands import start_convert_db
|
||||
from freqtrade.commands.deploy_commands import (
|
||||
from freqtrade.commands.deploy_ui import (
|
||||
clean_ui_subdir,
|
||||
download_and_install_ui,
|
||||
get_ui_download_url,
|
||||
@@ -612,13 +612,13 @@ def test_start_new_strategy_no_arg(mocker, caplog):
|
||||
|
||||
|
||||
def test_start_install_ui(mocker):
|
||||
clean_mock = mocker.patch("freqtrade.commands.deploy_commands.clean_ui_subdir")
|
||||
clean_mock = mocker.patch("freqtrade.commands.deploy_ui.clean_ui_subdir")
|
||||
get_url_mock = mocker.patch(
|
||||
"freqtrade.commands.deploy_commands.get_ui_download_url",
|
||||
"freqtrade.commands.deploy_ui.get_ui_download_url",
|
||||
return_value=("https://example.com/whatever", "0.0.1"),
|
||||
)
|
||||
download_mock = mocker.patch("freqtrade.commands.deploy_commands.download_and_install_ui")
|
||||
mocker.patch("freqtrade.commands.deploy_commands.read_ui_version", return_value=None)
|
||||
download_mock = mocker.patch("freqtrade.commands.deploy_ui.download_and_install_ui")
|
||||
mocker.patch("freqtrade.commands.deploy_ui.read_ui_version", return_value=None)
|
||||
args = [
|
||||
"install-ui",
|
||||
]
|
||||
@@ -642,13 +642,13 @@ def test_start_install_ui(mocker):
|
||||
|
||||
|
||||
def test_clean_ui_subdir(mocker, tmp_path, caplog):
|
||||
mocker.patch("freqtrade.commands.deploy_commands.Path.is_dir", side_effect=[True, True])
|
||||
mocker.patch("freqtrade.commands.deploy_commands.Path.is_file", side_effect=[False, True])
|
||||
rd_mock = mocker.patch("freqtrade.commands.deploy_commands.Path.rmdir")
|
||||
ul_mock = mocker.patch("freqtrade.commands.deploy_commands.Path.unlink")
|
||||
mocker.patch("freqtrade.commands.deploy_ui.Path.is_dir", side_effect=[True, True])
|
||||
mocker.patch("freqtrade.commands.deploy_ui.Path.is_file", side_effect=[False, True])
|
||||
rd_mock = mocker.patch("freqtrade.commands.deploy_ui.Path.rmdir")
|
||||
ul_mock = mocker.patch("freqtrade.commands.deploy_ui.Path.unlink")
|
||||
|
||||
mocker.patch(
|
||||
"freqtrade.commands.deploy_commands.Path.glob",
|
||||
"freqtrade.commands.deploy_ui.Path.glob",
|
||||
return_value=[Path("test1"), Path("test2"), Path(".gitkeep")],
|
||||
)
|
||||
folder = tmp_path / "uitests"
|
||||
@@ -668,10 +668,10 @@ def test_download_and_install_ui(mocker, tmp_path):
|
||||
file_like_object.seek(0)
|
||||
requests_mock.content = file_like_object.read()
|
||||
|
||||
mocker.patch("requests.get", return_value=requests_mock)
|
||||
mocker.patch("freqtrade.commands.deploy_ui.requests.get", return_value=requests_mock)
|
||||
|
||||
mocker.patch("freqtrade.commands.deploy_commands.Path.is_dir", side_effect=[True, False])
|
||||
wb_mock = mocker.patch("freqtrade.commands.deploy_commands.Path.write_bytes")
|
||||
mocker.patch("freqtrade.commands.deploy_ui.Path.is_dir", side_effect=[True, False])
|
||||
wb_mock = mocker.patch("freqtrade.commands.deploy_ui.Path.write_bytes")
|
||||
|
||||
folder = tmp_path / "uitests_dl"
|
||||
folder.mkdir(exist_ok=True)
|
||||
@@ -693,9 +693,7 @@ def test_get_ui_download_url(mocker):
|
||||
[{"browser_download_url": "http://download.zip"}],
|
||||
]
|
||||
)
|
||||
get_mock = mocker.patch(
|
||||
"freqtrade.commands.deploy_commands.requests.get", return_value=response
|
||||
)
|
||||
get_mock = mocker.patch("freqtrade.commands.deploy_ui.requests.get", return_value=response)
|
||||
x, last_version = get_ui_download_url()
|
||||
assert get_mock.call_count == 2
|
||||
assert last_version == "0.0.1"
|
||||
@@ -718,9 +716,7 @@ def test_get_ui_download_url_direct(mocker):
|
||||
},
|
||||
]
|
||||
)
|
||||
get_mock = mocker.patch(
|
||||
"freqtrade.commands.deploy_commands.requests.get", return_value=response
|
||||
)
|
||||
get_mock = mocker.patch("freqtrade.commands.deploy_ui.requests.get", return_value=response)
|
||||
x, last_version = get_ui_download_url()
|
||||
assert get_mock.call_count == 1
|
||||
assert last_version == "0.0.2"
|
||||
|
||||
Reference in New Issue
Block a user