[Add] added test to check None return for newest_xxx_data if database is empty
This commit is contained in:
parent
b72a1dc155
commit
6f3b66a05c
@ -67,6 +67,7 @@ tick = TickData(
|
|||||||
|
|
||||||
|
|
||||||
class TestDatabase(unittest.TestCase):
|
class TestDatabase(unittest.TestCase):
|
||||||
|
|
||||||
def connect(self, settings: dict):
|
def connect(self, settings: dict):
|
||||||
from vnpy.trader.database.initialize import init # noqa
|
from vnpy.trader.database.initialize import init # noqa
|
||||||
|
|
||||||
@ -145,6 +146,11 @@ class TestDatabase(unittest.TestCase):
|
|||||||
for driver, settings in profiles.items():
|
for driver, settings in profiles.items():
|
||||||
with self.subTest(driver=driver, settings=settings):
|
with self.subTest(driver=driver, settings=settings):
|
||||||
self.connect(settings)
|
self.connect(settings)
|
||||||
|
got = self.manager.get_newest_bar_data(bar.symbol, bar.exchange, bar.interval)
|
||||||
|
self.assertIsNone(
|
||||||
|
got,
|
||||||
|
"database is empty, but return value for newest_bar_data() is not a None"
|
||||||
|
)
|
||||||
|
|
||||||
# an older one
|
# an older one
|
||||||
older_one = copy(bar)
|
older_one = copy(bar)
|
||||||
@ -167,6 +173,11 @@ class TestDatabase(unittest.TestCase):
|
|||||||
with self.subTest(driver=driver, settings=settings):
|
with self.subTest(driver=driver, settings=settings):
|
||||||
self.connect(settings)
|
self.connect(settings)
|
||||||
|
|
||||||
|
got = self.manager.get_newest_tick_data(tick.symbol, tick.exchange)
|
||||||
|
self.assertIsNone(
|
||||||
|
got,
|
||||||
|
"database is empty, but return value for newest_tick_data() is not a None"
|
||||||
|
)
|
||||||
# an older one
|
# an older one
|
||||||
older_one = copy(tick)
|
older_one = copy(tick)
|
||||||
older_one.volume = 123
|
older_one.volume = 123
|
||||||
|
Loading…
Reference in New Issue
Block a user