Add migration test
This commit is contained in:
parent
f5ff6ceead
commit
49266fc4b8
@ -4,7 +4,7 @@ import os
|
||||
import pytest
|
||||
from sqlalchemy import create_engine
|
||||
|
||||
from freqtrade.persistence import Trade, init, clean_dry_run_db
|
||||
from freqtrade.persistence import Trade, init, clean_dry_run_db, check_migrate
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
@ -375,3 +375,40 @@ def test_clean_dry_run_db(default_conf, fee):
|
||||
|
||||
# We have now only the prod
|
||||
assert len(Trade.query.filter(Trade.open_order_id.isnot(None)).all()) == 1
|
||||
|
||||
|
||||
def test_migrate(default_conf, fee):
|
||||
create_table_old = """CREATE TABLE IF NOT EXISTS "trades" (
|
||||
id INTEGER NOT NULL,
|
||||
exchange VARCHAR NOT NULL,
|
||||
pair VARCHAR NOT NULL,
|
||||
is_open BOOLEAN NOT NULL,
|
||||
fee FLOAT NOT NULL,
|
||||
open_rate FLOAT,
|
||||
close_rate FLOAT,
|
||||
close_profit FLOAT,
|
||||
stake_amount FLOAT NOT NULL,
|
||||
amount FLOAT,
|
||||
open_date DATETIME NOT NULL,
|
||||
close_date DATETIME,
|
||||
open_order_id VARCHAR,
|
||||
PRIMARY KEY (id),
|
||||
CHECK (is_open IN (0, 1))
|
||||
);"""
|
||||
insert_table_old = """INSERT INTO trades (exchange, pair, is_open, fee,
|
||||
open_rate, stake_amount, amount, open_date)
|
||||
VALUES ('BITTREX', 'BTC_ETC', 1, {},
|
||||
0.00258580, 0.002, 0.7715262081,
|
||||
'2017-11-28 12:44:24.000000')""".format(fee.return_value)
|
||||
engine = create_engine('sqlite://')
|
||||
engine.execute(create_table_old)
|
||||
engine.execute(insert_table_old)
|
||||
init(default_conf, engine)
|
||||
assert len(Trade.query.filter(Trade.id == 1).all()) == 1
|
||||
trade = Trade.query.filter(Trade.id == 1).first()
|
||||
assert trade.fee_open == fee.return_value
|
||||
assert trade.fee_close == fee.return_value
|
||||
assert trade.open_rate_requested is None
|
||||
assert trade.close_rate_requested is None
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user