'Test the set_symbol_lookup_date API method.'

def test_set_symbol_lookup_date(self):

    dates = pd.date_range('2013-01-01', freq='2D', periods=2, tz='UTC')
    metadata = pd.DataFrame.from_records([{'sid': (i + 3), 'symbol': 'DUP', 'start_date': date.value, 'end_date': (date + timedelta(days=1)).value, 'exchange': 'TEST'} for (i, date) in enumerate(dates)])
    with tmp_trading_env(equities=metadata, load=self.make_load_function()) as env:
        algo = TradingAlgorithm(env=env)
        algo.sim_params = algo.sim_params.create_new(algo.sim_params.start_session, pd.Timestamp('2015-01-01', tz='UTC'))
        result = algo.symbol('DUP')
        self.assertEqual(result.symbol, 'DUP')
        for (i, date) in enumerate(dates):
            algo.set_symbol_lookup_date(date)
            result = algo.symbol('DUP')
            self.assertEqual(result.symbol, 'DUP')
            self.assertEqual(result.sid, (i + 3))
        with self.assertRaises(UnsupportedDatetimeFormat):
            algo.set_symbol_lookup_date('foobar')
