From ea3012e94d78c5119ba3b457a4799f2b714aafee Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Mar 2021 05:25:35 +0000 Subject: [PATCH 1/2] Bump sqlalchemy from 1.3.23 to 1.4.2 Bumps [sqlalchemy](https://github.com/sqlalchemy/sqlalchemy) from 1.3.23 to 1.4.2. - [Release notes](https://github.com/sqlalchemy/sqlalchemy/releases) - [Changelog](https://github.com/sqlalchemy/sqlalchemy/blob/master/CHANGES) - [Commits](https://github.com/sqlalchemy/sqlalchemy/commits) Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 08f5b9078..c714a8f1a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ ccxt==1.43.27 # Pin cryptography for now due to rust build errors with piwheels cryptography==3.4.6 aiohttp==3.7.4.post0 -SQLAlchemy==1.3.23 +SQLAlchemy==1.4.2 python-telegram-bot==13.4.1 arrow==1.0.3 cachetools==4.2.1 From b7702a1e9f121764605144d63c2480a2b82b08cd Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 22 Mar 2021 19:39:06 +0100 Subject: [PATCH 2/2] Improve tests to work with new sqlalchemy version --- tests/test_freqtradebot.py | 2 +- tests/test_persistence.py | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/tests/test_freqtradebot.py b/tests/test_freqtradebot.py index c1a17164f..486c31090 100644 --- a/tests/test_freqtradebot.py +++ b/tests/test_freqtradebot.py @@ -2798,7 +2798,7 @@ def test_execute_sell_sloe_cancel_exception(mocker, default_conf, ticker, fee, c mocker.patch('freqtrade.exchange.Exchange.cancel_stoploss_order', side_effect=InvalidOrderException()) mocker.patch('freqtrade.wallets.Wallets.get_free', MagicMock(return_value=300)) - sellmock = MagicMock() + sellmock = MagicMock(return_value={'id': '12345555'}) patch_exchange(mocker) mocker.patch.multiple( 'freqtrade.exchange.Exchange', diff --git a/tests/test_persistence.py b/tests/test_persistence.py index 1820250a5..6a388327c 100644 --- a/tests/test_persistence.py +++ b/tests/test_persistence.py @@ -1,6 +1,7 @@ # pragma pylint: disable=missing-docstring, C0103 import logging from datetime import datetime, timedelta, timezone +from pathlib import Path from types import FunctionType from unittest.mock import MagicMock @@ -21,14 +22,15 @@ def test_init_create_session(default_conf): assert 'scoped_session' in type(Trade.session).__name__ -def test_init_custom_db_url(default_conf, mocker): +def test_init_custom_db_url(default_conf, tmpdir): # Update path to a value other than default, but still in-memory - default_conf.update({'db_url': 'sqlite:///tmp/freqtrade2_test.sqlite'}) - create_engine_mock = mocker.patch('freqtrade.persistence.models.create_engine', MagicMock()) + filename = f"{tmpdir}/freqtrade2_test.sqlite" + assert not Path(filename).is_file() + + default_conf.update({'db_url': f'sqlite:///{filename}'}) init_db(default_conf['db_url'], default_conf['dry_run']) - assert create_engine_mock.call_count == 1 - assert create_engine_mock.mock_calls[0][1][0] == 'sqlite:///tmp/freqtrade2_test.sqlite' + assert Path(filename).is_file() def test_init_invalid_db_url(default_conf): @@ -49,15 +51,16 @@ def test_init_prod_db(default_conf, mocker): assert create_engine_mock.mock_calls[0][1][0] == 'sqlite:///tradesv3.sqlite' -def test_init_dryrun_db(default_conf, mocker): - default_conf.update({'dry_run': True}) - default_conf.update({'db_url': constants.DEFAULT_DB_DRYRUN_URL}) - - create_engine_mock = mocker.patch('freqtrade.persistence.models.create_engine', MagicMock()) +def test_init_dryrun_db(default_conf, tmpdir): + filename = f"{tmpdir}/freqtrade2_prod.sqlite" + assert not Path(filename).is_file() + default_conf.update({ + 'dry_run': True, + 'db_url': f'sqlite:///{filename}' + }) init_db(default_conf['db_url'], default_conf['dry_run']) - assert create_engine_mock.call_count == 1 - assert create_engine_mock.mock_calls[0][1][0] == 'sqlite:///tradesv3.dryrun.sqlite' + assert Path(filename).is_file() @pytest.mark.usefixtures("init_persistence")