Skip to content

Commit

Permalink
Merge pull request #1452 from quantopian/begin-cover-reindex-resample
Browse files Browse the repository at this point in the history
TST: Increase coverage for  reindex reader methods
  • Loading branch information
ehebert committed Aug 31, 2016
2 parents 8c2ed2f + 0cba47e commit 34b113f
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions tests/data/test_resample.py
Expand Up @@ -11,6 +11,8 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from unittest import skip

from collections import OrderedDict
from numbers import Real

Expand Down Expand Up @@ -619,18 +621,21 @@ class TestReindexSessionBars(WithBcolzEquityDailyBarReader,
START_DATE = pd.Timestamp('2015-11-01', tz='UTC')
END_DATE = pd.Timestamp('2015-11-30', tz='UTC')

def test_load_raw_arrays(self):
reindex_reader = ReindexSessionBarReader(
def init_instance_fixtures(self):
super(TestReindexSessionBars, self).init_instance_fixtures()

self.reader = ReindexSessionBarReader(
self.trading_calendar,
self.bcolz_equity_daily_bar_reader,
self.START_DATE,
self.END_DATE,
)

def test_load_raw_arrays(self):
outer_sessions = self.trading_calendar.sessions_in_range(
self.START_DATE, self.END_DATE)

result = reindex_reader.load_raw_arrays(
result = self.reader.load_raw_arrays(
OHLCV, self.START_DATE, self.END_DATE, [1, 2])

opens = DataFrame(data=result[0], index=outer_sessions,
Expand All @@ -657,3 +662,16 @@ def test_load_raw_arrays(self):
opens[1][tday_loc],
err_msg="2015-11-26 should be `nan`, since Thanksgiving is a "
"holiday in the reader's calendar.")

def test_last_availabe_dt(self):
self.assertEqual(self.reader.last_available_dt, self.END_DATE)

@skip("This test revealed a bug in BcolzDailyBarReader.get_last_traded_dt."
" When requesting data on the last session of an asset, the date is "
"overriden by the previous day. When that errant handling is this "
"test should be enabled.")
def test_get_last_traded_dt(self):
asset = self.asset_finder.retrieve_asset(1)
self.assertEqual(self.reader.get_last_traded_dt(asset,
self.END_DATE),
self.END_DATE)

0 comments on commit 34b113f

Please sign in to comment.