-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test case for task utils and sec_synctask also amend documentation for abstract_quotes_fetcher
- Loading branch information
aaron yang
committed
Jul 24, 2022
1 parent
3479e45
commit 30e40b4
Showing
5 changed files
with
80 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import unittest | ||
from tests import init_test_env | ||
import omicron | ||
from omega.worker.tasks.sec_synctask import sync_xrxd_report_list | ||
import datetime | ||
from omicron import cache | ||
import cfg4py | ||
from omega.worker.abstract_quotes_fetcher import AbstractQuotesFetcher as aq | ||
|
||
|
||
class SecSyncTaskTest(unittest.IsolatedAsyncioTestCase): | ||
async def asyncSetUp(self) -> None: | ||
await init_test_env() | ||
await omicron.init() | ||
await self.create_quotes_fetcher() | ||
|
||
async def asyncTearDown(self) -> None: | ||
await omicron.close() | ||
|
||
async def create_quotes_fetcher(self): | ||
cfg = cfg4py.get_instance() | ||
fetcher_info = cfg.quotes_fetchers[0] | ||
impl = fetcher_info["impl"] | ||
params = fetcher_info["workers"][0] | ||
await aq.create_instance(impl, **params) | ||
|
||
async def test_sync_xrxd_report_list(self): | ||
# fixme: 先清除掉influxdb和缓存 | ||
await cache.sys.hmset("ut:sec:xrxd:report", "worker_count", "0") | ||
await sync_xrxd_report_list( | ||
{ | ||
"end": datetime.date(2022, 6, 30), | ||
"state": "start", | ||
"timeout": 20, | ||
"name": "ut_sync_xrxd", | ||
} | ||
) | ||
|
||
# fixme: how to check result? 这里应该检查influxdb和缓存中的数据是否如期望 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import unittest | ||
from omega.worker.tasks.task_utils import cache_init | ||
from tests import init_test_env | ||
import omicron | ||
from omicron import cache | ||
import cfg4py | ||
from omega.worker.abstract_quotes_fetcher import AbstractQuotesFetcher as aq | ||
|
||
|
||
class TaskUtilsTest(unittest.IsolatedAsyncioTestCase): | ||
async def asyncSetUp(self) -> None: | ||
await init_test_env() | ||
await omicron.init() | ||
await self.create_quotes_fetcher() | ||
|
||
async def create_quotes_fetcher(self): | ||
cfg = cfg4py.get_instance() | ||
fetcher_info = cfg.quotes_fetchers[0] | ||
impl = fetcher_info["impl"] | ||
params = fetcher_info["workers"][0] | ||
await aq.create_instance(impl, **params) | ||
|
||
async def asyncTearDown(self) -> None: | ||
await omicron.close() | ||
|
||
async def test_cache_init(self): | ||
await cache.security.delete("calendar:1d") | ||
await cache.security.delete("security:all") | ||
await cache_init() | ||
self.assertTrue(cache.security.exists("calendar:1d")) | ||
self.assertTrue(cache.security.exists("security:all")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters