def test_read(): self = create_autospec(TopLevelTickStore) tsl = TickStoreLibrary(create_autospec(TickStore), create_autospec(DateRange)) self._get_libraries.return_value = [tsl, tsl] dr = create_autospec(DateRange) with patch('pandas.concat') as concat: res = TopLevelTickStore.read(self, sentinel.symbol, dr, columns=sentinel.include_columns, include_images=sentinel.include_images) assert concat.call_args_list == [ call([tsl.library.read.return_value, tsl.library.read.return_value]) ] assert res == concat.return_value assert tsl.library.read.call_args_list == [ call(sentinel.symbol, tsl.date_range.intersection.return_value, sentinel.include_columns, include_images=sentinel.include_images), call(sentinel.symbol, tsl.date_range.intersection.return_value, sentinel.include_columns, include_images=sentinel.include_images) ]
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)