コード例 #1
0
ファイル: test_toplevel.py プロジェクト: JianfengYu/arctic
def test_add_library_to_colllection_if_date_range_is_on_UTC_or_naive_day_boundaries(start, end, expected_start, expected_end):
    self = create_autospec(TopLevelTickStore, _arctic_lib=MagicMock(), _collection=MagicMock())
    self._get_library_metadata.return_value = []
    TopLevelTickStore.add(self, DateRange(start=start, end=end), "blah")
    self._collection.update_one.assert_called_once_with({'library_name': "blah"},
                                                        {'$set':
                                                         {'start': expected_start,
                                                          'end': expected_end}}, upsert=True)
コード例 #2
0
ファイル: test_toplevel.py プロジェクト: rsheftel/arctic
def test_raise_exception_and_log_an_error_if_an_invalid_library_name_is_added():
    arctic_lib = MagicMock()
    arctic_lib.arctic.__getitem__.side_effect = Exception()
    store = TopLevelTickStore(arctic_lib)
    with patch("arctic.tickstore.toplevel.logger") as mock_logger:
        with pytest.raises(Exception):
            store.add(None, "blah")
    mock_logger.error.assert_called_once_with("Could not load library")
コード例 #3
0
ファイル: test_toplevel.py プロジェクト: ceallen/arctic
def test_add_library_to_colllection_if_date_range_is_on_UTC_or_naive_day_boundaries(start, end, expected_start, expected_end):
    self = create_autospec(TopLevelTickStore, _arctic_lib=MagicMock(), _collection=MagicMock())
    self._get_library_metadata.return_value = []
    TopLevelTickStore.add(self, DateRange(start=start, end=end), "blah")
    self._collection.update_one.assert_called_once_with({'library_name': "blah"},
                                                        {'$set':
                                                         {'start': expected_start,
                                                          'end': expected_end}}, upsert=True)
コード例 #4
0
ファイル: test_toplevel.py プロジェクト: ceallen/arctic
def test_raise_exception_and_log_an_error_if_an_invalid_library_name_is_added():
    arctic_lib = MagicMock()
    arctic_lib.arctic.__getitem__.side_effect = Exception()
    store = TopLevelTickStore(arctic_lib)
    with patch("arctic.tickstore.toplevel.logger") as mock_logger:
        with pytest.raises(Exception):
            store.add(None, "blah")
    mock_logger.error.assert_called_once_with("Could not load library")
コード例 #5
0
def test_raise_error_add_library_is_called_with_a_date_range_not_on_day_boundaries(
        start, end):
    with pytest.raises(AssertionError) as e:
        self = create_autospec(TopLevelTickStore,
                               _arctic_lib=MagicMock(),
                               _collection=MagicMock())
        self._get_library_metadata.return_value = []
        TopLevelTickStore.add(self, DateRange(start=start, end=end), "blah")
    assert "Date range should fall on UTC day boundaries" in str(e)
コード例 #6
0
def test_raise_exception_if_date_range_overlaps():
    self = create_autospec(TopLevelTickStore, _arctic_lib=MagicMock())
    self._get_library_metadata.return_value = [
        TickStoreLibrary('lib1', None),
    ]
    with pytest.raises(OverlappingDataException) as e:
        TopLevelTickStore.add(
            self,
            DateRange(start=dt(2010, 1, 1),
                      end=dt(2011, 1, 1, 23, 59, 59, 999000)), "blah")
    assert "There are libraries that overlap with the date range:" in str(e)
コード例 #7
0
ファイル: test_toplevel.py プロジェクト: rsheftel/arctic
def test_raise_exception_if_date_range_overlaps():
    self = create_autospec(TopLevelTickStore, _arctic_lib=MagicMock())
    self._get_library_metadata.return_value = [TickStoreLibrary("lib1", None)]
    with pytest.raises(OverlappingDataException) as e:
        TopLevelTickStore.add(self, DateRange(start=dt(2010, 1, 1), end=dt(2011, 1, 1, 23, 59, 59, 999000)), "blah")
    assert "There are libraries that overlap with the date range:" in str(e)
コード例 #8
0
ファイル: test_toplevel.py プロジェクト: rsheftel/arctic
def test_raise_error_add_library_is_called_with_a_date_range_not_on_day_boundaries(start, end):
    with pytest.raises(AssertionError) as e:
        self = create_autospec(TopLevelTickStore, _arctic_lib=MagicMock(), _collection=MagicMock())
        self._get_library_metadata.return_value = []
        TopLevelTickStore.add(self, DateRange(start=start, end=end), "blah")
    assert "Date range should fall on UTC day boundaries" in str(e)