當前位置: 首頁>>代碼示例>>Python>>正文


Python TickStore._mongo_date_range_query方法代碼示例

本文整理匯總了Python中arctic.tickstore.tickstore.TickStore._mongo_date_range_query方法的典型用法代碼示例。如果您正苦於以下問題:Python TickStore._mongo_date_range_query方法的具體用法?Python TickStore._mongo_date_range_query怎麽用?Python TickStore._mongo_date_range_query使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在arctic.tickstore.tickstore.TickStore的用法示例。


在下文中一共展示了TickStore._mongo_date_range_query方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_mongo_date_range_query

# 需要導入模塊: from arctic.tickstore.tickstore import TickStore [as 別名]
# 或者: from arctic.tickstore.tickstore.TickStore import _mongo_date_range_query [as 別名]
def test_mongo_date_range_query():
    self = create_autospec(TickStore)
    self._collection = create_autospec(Collection)
    self._symbol_query.return_value = {"sy": {"$in" : ["s1" , "s2"]}}
    self._collection.aggregate.return_value = iter([{"_id": "s1", "start": dt(2014, 1, 1, 0, 0, tzinfo=mktz())},
                                                    {"_id": "s2", "start": dt(2014, 1, 1, 12, 0, tzinfo=mktz())}])

    self._collection.find_one.side_effect = [
        {'e': dt(2014, 1, 1, 15, 0, tzinfo=mktz())},
        {'e': dt(2014, 1, 2, 12, 0, tzinfo=mktz())}]

    query = TickStore._mongo_date_range_query(self, 'sym', DateRange(dt(2014, 1, 2, 0, 0, tzinfo=mktz()),
                                                                     dt(2014, 1, 3, 0, 0, tzinfo=mktz())))

    assert self._collection.aggregate.call_args_list == [call([
     {"$match": {"s": {"$lte": dt(2014, 1, 2, 0, 0, tzinfo=mktz())}, "sy": {"$in" : ["s1" , "s2"]}}},
     {"$project": {"_id": 0, "s": 1, "sy": 1}},
     {"$group": {"_id": "$sy", "start": {"$max": "$s"}}},
     {"$sort": {"start": 1}}])]

    assert self._collection.find_one.call_args_list == [
        call({'sy': 's1', 's': dt(2014, 1, 1, 0, 0, tzinfo=mktz())}, {'e': 1}),
        call({'sy': 's2', 's': dt(2014, 1, 1, 12, 0, tzinfo=mktz())}, {'e': 1})]

    assert query == {'s': {'$gte': dt(2014, 1, 1, 12, 0, tzinfo=mktz()), '$lte': dt(2014, 1, 3, 0, 0, tzinfo=mktz())}}
開發者ID:manahl,項目名稱:arctic,代碼行數:27,代碼來源:test_tickstore.py

示例2: test_mongo_date_range_query

# 需要導入模塊: from arctic.tickstore.tickstore import TickStore [as 別名]
# 或者: from arctic.tickstore.tickstore.TickStore import _mongo_date_range_query [as 別名]
def test_mongo_date_range_query():
    self = create_autospec(TickStore)
    self._collection = create_autospec(Collection)
    self._collection.find_one.return_value = {'s': sentinel.start}
    self._symbol_query = partial(TickStore._symbol_query, self)
    query = TickStore._mongo_date_range_query(self, 'sym', DateRange(dt(2014, 1, 1, 0, 0, tzinfo=mktz()),
                                                                     dt(2014, 1, 2, 0, 0, tzinfo=mktz())))
    assert self._collection.find_one.call_args_list == [call({'sy': 'sym', 's': {'$lte': dt(2014, 1, 1, 0, 0, tzinfo=mktz())}},
                                                             sort=[('s', -1)], projection={'s': 1, '_id': 0}),
                                                        call({'sy': 'sym', 's': {'$gt': dt(2014, 1, 2, 0, 0, tzinfo=mktz())}},
                                                             sort=[('s', 1)], projection={'s': 1, '_id': 0})]
    assert query == {'s': {'$gte': sentinel.start, '$lt': sentinel.start}}
開發者ID:bigtonylewis,項目名稱:arctic,代碼行數:14,代碼來源:test_tickstore.py

示例3: test_mongo_date_range_query_asserts

# 需要導入模塊: from arctic.tickstore.tickstore import TickStore [as 別名]
# 或者: from arctic.tickstore.tickstore.TickStore import _mongo_date_range_query [as 別名]
def test_mongo_date_range_query_asserts():
    self = create_autospec(TickStore)
    self._collection = create_autospec(Collection)
    self._collection.find_one.return_value = {'s': sentinel.start}
    with pytest.raises(AssertionError):
        TickStore._mongo_date_range_query(self, 'sym', DateRange(None, None, CLOSED_OPEN))

    with pytest.raises(AssertionError):
        TickStore._mongo_date_range_query(self, 'sym', DateRange(dt(2014, 1, 1), None))

    with pytest.raises(AssertionError):
        TickStore._mongo_date_range_query(self, 'sym', DateRange(None, dt(2014, 1, 1)))
開發者ID:bigtonylewis,項目名稱:arctic,代碼行數:14,代碼來源:test_tickstore.py

示例4: test_mongo_date_range_query

# 需要導入模塊: from arctic.tickstore.tickstore import TickStore [as 別名]
# 或者: from arctic.tickstore.tickstore.TickStore import _mongo_date_range_query [as 別名]
def test_mongo_date_range_query():
    self = create_autospec(TickStore)
    self._collection = create_autospec(Collection)
    self._collection.find_one.return_value = {"s": sentinel.start}
    self._symbol_query = partial(TickStore._symbol_query, self)
    query = TickStore._mongo_date_range_query(
        self, "sym", DateRange(dt(2014, 1, 1, 0, 0, tzinfo=mktz()), dt(2014, 1, 2, 0, 0, tzinfo=mktz()))
    )
    assert self._collection.find_one.call_args_list == [
        call(
            {"sy": "sym", "s": {"$lte": dt(2014, 1, 1, 0, 0, tzinfo=mktz())}},
            sort=[("s", -1)],
            projection={"s": 1, "_id": 0},
        ),
        call(
            {"sy": "sym", "s": {"$gt": dt(2014, 1, 2, 0, 0, tzinfo=mktz())}},
            sort=[("s", 1)],
            projection={"s": 1, "_id": 0},
        ),
    ]
    assert query == {"s": {"$gte": sentinel.start, "$lt": sentinel.start}}
開發者ID:rsheftel,項目名稱:arctic,代碼行數:23,代碼來源:test_tickstore.py


注:本文中的arctic.tickstore.tickstore.TickStore._mongo_date_range_query方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。