'input (df):
asof_date  int_value  sid           timestamp  value
0 2013-12-31          0   65 2014-01-01 13:44:00    0.0
1 2013-12-31          1   66 2014-01-01 13:44:00    1.0
2 2013-12-31          2   67 2014-01-01 13:44:00    2.0
3 2013-12-31          1   65 2014-01-01 13:45:00    1.0
4 2013-12-31          2   66 2014-01-01 13:45:00    2.0
5 2013-12-31          3   67 2014-01-01 13:45:00    3.0
6 2014-01-02          2   65 2014-01-03 13:44:00    2.0
7 2014-01-02          3   66 2014-01-03 13:44:00    3.0
8 2014-01-02          4   67 2014-01-03 13:44:00    4.0
output (expected):
int_value  value
2014-01-01 00:00:00+00:00 Equity(65 [A])          0    0.0
Equity(66 [B])          1    1.0
Equity(67 [C])          2    2.0
2014-01-02 00:00:00+00:00 Equity(65 [A])          1    1.0
Equity(66 [B])          2    2.0
Equity(67 [C])          3    3.0
2014-01-03 00:00:00+00:00 Equity(65 [A])          2    2.0
Equity(66 [B])          3    3.0
Equity(67 [C])          4    4.0'

def test_custom_query_time_tz(self):

    df = self.df.copy()
    df['timestamp'] = (pd.DatetimeIndex(df['timestamp'], tz='EST') + timedelta(hours=8, minutes=44)).tz_convert('utc').tz_localize(None)
    df.ix[3:5, 'timestamp'] = pd.Timestamp('2014-01-01    13:45')
    expr = bz.data(df, name='expr', dshape=self.dshape)
    loader = BlazeLoader(data_query_time=time(8, 45), data_query_tz='EST')
    ds = from_blaze(expr, loader=loader, no_deltas_rule='ignore', no_checkpoints_rule='ignore', missing_values=self.missing_values)
    p = Pipeline()
    p.add(ds.value.latest, 'value')
    p.add(ds.int_value.latest, 'int_value')
    dates = self.dates
    result = SimplePipelineEngine(loader, dates, self.asset_finder).run_pipeline(p, dates[0], dates[(-1)])
    expected = df.drop('asof_date', axis=1)
    expected['timestamp'] = expected['timestamp'].dt.normalize().astype('datetime64[ns]').dt.tz_localize('utc')
    expected.ix[3:5, 'timestamp'] += timedelta(days=1)
    expected.set_index(['timestamp', 'sid'], inplace=True)
    expected.index = pd.MultiIndex.from_product((expected.index.levels[0], self.asset_finder.retrieve_all(expected.index.levels[1])))
    assert_frame_equal(result, expected, check_dtype=False)
