|
1 |
| -from mock import Mock, patch, MagicMock, create_autospec, sentinel |
| 1 | +from mock import Mock, patch, MagicMock, create_autospec, sentinel, call |
2 | 2 | import pytest
|
3 | 3 | from datetime import datetime as dt
|
4 | 4 | import pandas as pd
|
|
10 | 10 | from arctic.exceptions import OverlappingDataException
|
11 | 11 | from arctic.tickstore.toplevel import TopLevelTickStore, TickStoreLibrary
|
12 | 12 | from dateutil.rrule import rrule, DAILY
|
| 13 | +from arctic.tickstore.tickstore import TickStore |
13 | 14 |
|
14 | 15 |
|
15 | 16 | def test_raise_exception_if_daterange_is_not_provided():
|
@@ -145,3 +146,21 @@ def test_write_pandas_data_to_right_libraries():
|
145 | 146 | TopLevelTickStore.write(self, 'blah', sentinel.data)
|
146 | 147 | mock_lib1.write.assert_called_once_with('blah', slice1)
|
147 | 148 | mock_lib2.write.assert_called_once_with('blah', slice2)
|
| 149 | + |
| 150 | + |
| 151 | +def test_read(): |
| 152 | + self = create_autospec(TopLevelTickStore) |
| 153 | + tsl = TickStoreLibrary(create_autospec(TickStore), create_autospec(DateRange)) |
| 154 | + self._get_libraries.return_value = [tsl, tsl] |
| 155 | + dr = create_autospec(DateRange) |
| 156 | + with patch('pandas.concat') as concat: |
| 157 | + res = TopLevelTickStore.read(self, sentinel.symbol, dr, |
| 158 | + columns=sentinel.include_columns, |
| 159 | + include_images=sentinel.include_images) |
| 160 | + assert concat.call_args_list == [call([tsl.library.read.return_value, |
| 161 | + tsl.library.read.return_value])] |
| 162 | + assert res == concat.return_value |
| 163 | + assert tsl.library.read.call_args_list == [call(sentinel.symbol, tsl.date_range.intersection.return_value, |
| 164 | + sentinel.include_columns, include_images=sentinel.include_images), |
| 165 | + call(sentinel.symbol, tsl.date_range.intersection.return_value, |
| 166 | + sentinel.include_columns, include_images=sentinel.include_images)] |
0 commit comments