|  |  |  | @@ -13,12 +13,12 @@ from freqtrade.tests.conftest import log_has | 
		
	
		
			
				|  |  |  |  |  | 
		
	
		
			
				|  |  |  |  | @pytest.fixture(scope='function') | 
		
	
		
			
				|  |  |  |  | def init_persistence(default_conf): | 
		
	
		
			
				|  |  |  |  |     init(default_conf) | 
		
	
		
			
				|  |  |  |  |     init(default_conf['db_url'], default_conf['dry_run']) | 
		
	
		
			
				|  |  |  |  |  | 
		
	
		
			
				|  |  |  |  |  | 
		
	
		
			
				|  |  |  |  | def test_init_create_session(default_conf): | 
		
	
		
			
				|  |  |  |  |     # Check if init create a session | 
		
	
		
			
				|  |  |  |  |     init(default_conf) | 
		
	
		
			
				|  |  |  |  |     init(default_conf['db_url'], default_conf['dry_run']) | 
		
	
		
			
				|  |  |  |  |     assert hasattr(Trade, 'session') | 
		
	
		
			
				|  |  |  |  |     assert 'Session' in type(Trade.session).__name__ | 
		
	
		
			
				|  |  |  |  |  | 
		
	
	
		
			
				
					
					|  |  |  | @@ -28,7 +28,7 @@ def test_init_custom_db_url(default_conf, mocker): | 
		
	
		
			
				|  |  |  |  |     default_conf.update({'db_url': 'sqlite:///tmp/freqtrade2_test.sqlite'}) | 
		
	
		
			
				|  |  |  |  |     create_engine_mock = mocker.patch('freqtrade.persistence.create_engine', MagicMock()) | 
		
	
		
			
				|  |  |  |  |  | 
		
	
		
			
				|  |  |  |  |     init(default_conf) | 
		
	
		
			
				|  |  |  |  |     init(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' | 
		
	
		
			
				|  |  |  |  |  | 
		
	
	
		
			
				
					
					|  |  |  | @@ -37,7 +37,7 @@ def test_init_invalid_db_url(default_conf): | 
		
	
		
			
				|  |  |  |  |     # Update path to a value other than default, but still in-memory | 
		
	
		
			
				|  |  |  |  |     default_conf.update({'db_url': 'unknown:///some.url'}) | 
		
	
		
			
				|  |  |  |  |     with pytest.raises(OperationalException, match=r'.*no valid database URL*'): | 
		
	
		
			
				|  |  |  |  |         init(default_conf) | 
		
	
		
			
				|  |  |  |  |         init(default_conf['db_url'], default_conf['dry_run']) | 
		
	
		
			
				|  |  |  |  |  | 
		
	
		
			
				|  |  |  |  |  | 
		
	
		
			
				|  |  |  |  | def test_init_prod_db(default_conf, mocker): | 
		
	
	
		
			
				
					
					|  |  |  | @@ -46,7 +46,7 @@ def test_init_prod_db(default_conf, mocker): | 
		
	
		
			
				|  |  |  |  |  | 
		
	
		
			
				|  |  |  |  |     create_engine_mock = mocker.patch('freqtrade.persistence.create_engine', MagicMock()) | 
		
	
		
			
				|  |  |  |  |  | 
		
	
		
			
				|  |  |  |  |     init(default_conf) | 
		
	
		
			
				|  |  |  |  |     init(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.sqlite' | 
		
	
		
			
				|  |  |  |  |  | 
		
	
	
		
			
				
					
					|  |  |  | @@ -57,7 +57,7 @@ def test_init_dryrun_db(default_conf, mocker): | 
		
	
		
			
				|  |  |  |  |  | 
		
	
		
			
				|  |  |  |  |     create_engine_mock = mocker.patch('freqtrade.persistence.create_engine', MagicMock()) | 
		
	
		
			
				|  |  |  |  |  | 
		
	
		
			
				|  |  |  |  |     init(default_conf) | 
		
	
		
			
				|  |  |  |  |     init(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://' | 
		
	
		
			
				|  |  |  |  |  | 
		
	
	
		
			
				
					
					|  |  |  | @@ -336,8 +336,8 @@ def test_calc_profit_percent(limit_buy_order, limit_sell_order, fee): | 
		
	
		
			
				|  |  |  |  |     assert trade.calc_profit_percent(fee=0.003) == 0.06147824 | 
		
	
		
			
				|  |  |  |  |  | 
		
	
		
			
				|  |  |  |  |  | 
		
	
		
			
				|  |  |  |  | @pytest.mark.usefixtures("init_persistence") | 
		
	
		
			
				|  |  |  |  | def test_clean_dry_run_db(default_conf, fee): | 
		
	
		
			
				|  |  |  |  |     init(default_conf) | 
		
	
		
			
				|  |  |  |  |  | 
		
	
		
			
				|  |  |  |  |     # Simulate dry_run entries | 
		
	
		
			
				|  |  |  |  |     trade = Trade( | 
		
	
	
		
			
				
					
					|  |  |  | @@ -424,7 +424,7 @@ def test_migrate_old(mocker, default_conf, fee): | 
		
	
		
			
				|  |  |  |  |     engine.execute(create_table_old) | 
		
	
		
			
				|  |  |  |  |     engine.execute(insert_table_old) | 
		
	
		
			
				|  |  |  |  |     # Run init to test migration | 
		
	
		
			
				|  |  |  |  |     init(default_conf) | 
		
	
		
			
				|  |  |  |  |     init(default_conf['db_url'], default_conf['dry_run']) | 
		
	
		
			
				|  |  |  |  |  | 
		
	
		
			
				|  |  |  |  |     assert len(Trade.query.filter(Trade.id == 1).all()) == 1 | 
		
	
		
			
				|  |  |  |  |     trade = Trade.query.filter(Trade.id == 1).first() | 
		
	
	
		
			
				
					
					|  |  |  | @@ -497,7 +497,7 @@ def test_migrate_new(mocker, default_conf, fee, caplog): | 
		
	
		
			
				|  |  |  |  |  | 
		
	
		
			
				|  |  |  |  |     engine.execute("create table trades_bak1 as select * from trades") | 
		
	
		
			
				|  |  |  |  |     # Run init to test migration | 
		
	
		
			
				|  |  |  |  |     init(default_conf) | 
		
	
		
			
				|  |  |  |  |     init(default_conf['db_url'], default_conf['dry_run']) | 
		
	
		
			
				|  |  |  |  |  | 
		
	
		
			
				|  |  |  |  |     assert len(Trade.query.filter(Trade.id == 1).all()) == 1 | 
		
	
		
			
				|  |  |  |  |     trade = Trade.query.filter(Trade.id == 1).first() | 
		
	
	
		
			
				
					
					|  |  |  | @@ -566,7 +566,7 @@ def test_migrate_mid_state(mocker, default_conf, fee, caplog): | 
		
	
		
			
				|  |  |  |  |     engine.execute(insert_table_old) | 
		
	
		
			
				|  |  |  |  |  | 
		
	
		
			
				|  |  |  |  |     # Run init to test migration | 
		
	
		
			
				|  |  |  |  |     init(default_conf) | 
		
	
		
			
				|  |  |  |  |     init(default_conf['db_url'], default_conf['dry_run']) | 
		
	
		
			
				|  |  |  |  |  | 
		
	
		
			
				|  |  |  |  |     assert len(Trade.query.filter(Trade.id == 1).all()) == 1 | 
		
	
		
			
				|  |  |  |  |     trade = Trade.query.filter(Trade.id == 1).first() | 
		
	
	
		
			
				
					
					|  |  |  | @@ -668,8 +668,8 @@ def test_adjust_min_max_rates(fee): | 
		
	
		
			
				|  |  |  |  |     assert trade.min_rate == 0.96 | 
		
	
		
			
				|  |  |  |  |  | 
		
	
		
			
				|  |  |  |  |  | 
		
	
		
			
				|  |  |  |  | @pytest.mark.usefixtures("init_persistence") | 
		
	
		
			
				|  |  |  |  | def test_get_open(default_conf, fee): | 
		
	
		
			
				|  |  |  |  |     init(default_conf) | 
		
	
		
			
				|  |  |  |  |  | 
		
	
		
			
				|  |  |  |  |     # Simulate dry_run entries | 
		
	
		
			
				|  |  |  |  |     trade = Trade( | 
		
	
	
		
			
				
					
					|  |  |  | @@ -713,8 +713,8 @@ def test_get_open(default_conf, fee): | 
		
	
		
			
				|  |  |  |  |     assert len(Trade.get_open_trades()) == 2 | 
		
	
		
			
				|  |  |  |  |  | 
		
	
		
			
				|  |  |  |  |  | 
		
	
		
			
				|  |  |  |  | @pytest.mark.usefixtures("init_persistence") | 
		
	
		
			
				|  |  |  |  | def test_to_json(default_conf, fee): | 
		
	
		
			
				|  |  |  |  |     init(default_conf) | 
		
	
		
			
				|  |  |  |  |  | 
		
	
		
			
				|  |  |  |  |     # Simulate dry_run entries | 
		
	
		
			
				|  |  |  |  |     trade = Trade( | 
		
	
	
		
			
				
					
					|  |  |  |   |