docstr: Test that the new and old data APIs hit the same code paths.
  
  We want to ensure that the old data API(data[sid(N)].field and
  similar)  and the new data API(data.current(sid(N), field) and
  similar) hit the same code paths on the DataPortal.
docstr_tok: ["Test","that","the","new","and","old","data","APIs","hit","the","same","code","paths",".","We","want","to","ensure","that","the","old","data","API","(","data","[","sid","(","N",")","]",".field","and","similar",")","and","the","new","data","API","(","data.current","(","sid","(","N",")",",","field",")","and","similar",")","hit","the","same","code","paths","on","the","DataPortal","."]
code: def test_old_new_data_api_paths(self):
      """
      Test that the new and old data APIs hit the same code paths.
  
      We want to ensure that the old data API(data[sid(N)].field and
      similar)  and the new data API(data.current(sid(N), field) and
      similar) hit the same code paths on the DataPortal.
      """
      test_start_minute = self.trading_calendar.minutes_for_session(
          self.sim_params.sessions[0]
      )[1]
      test_end_minute = self.trading_calendar.minutes_for_session(
          self.sim_params.sessions[0]
      )[-1]
      bar_data = self.create_bardata(
          lambda: test_end_minute,
      )
      ohlcvp_fields = [
          "open",
          "high",
          "low" "close",
          "volume",
          "price",
      ]
      spot_value_meth = (
          "zipline.data.data_portal.DataPortal.get_spot_value"
      )
  
      def assert_get_spot_value_called(fun, field):
          """
          Assert that get_spot_value was called during the execution of fun.
  
          Takes in a function fun and a string field.
          """
          with patch(spot_value_meth) as gsv:
              fun()
              gsv.assert_called_with(
                  self.asset1, field, test_end_minute, "minute"
              )
  
      # Ensure that data.current(sid(n), field) has the same behaviour as
      # data[sid(n)].field.
      for field in ohlcvp_fields:
          assert_get_spot_value_called(
              lambda: getattr(bar_data[self.asset1], field),
              field,
          )
          assert_get_spot_value_called(
              lambda: bar_data.current(self.asset1, field),
              field,
          )
  
      history_meth = (
          "zipline.data.data_portal.DataPortal.get_history_window"
      )
  
      def assert_get_history_window_called(fun, is_legacy):
          """
          Assert that get_history_window was called during fun().
  
          Takes in a function fun and a boolean is_legacy.
          """
          with patch(history_meth) as ghw:
              fun()
              # Slightly hacky, but done to get around the fact that
              # history( explicitly passes an ffill param as the last arg,
              # while data.history doesn't.
              if is_legacy:
                  ghw.assert_called_with(
                      [self.asset1, self.asset2, self.asset3],
                      test_end_minute,
                      5,
                      "1m",
                      "volume",
                      "minute",
                      True,
                  )
              else:
                  ghw.assert_called_with(
                      [self.asset1, self.asset2, self.asset3],
                      test_end_minute,
                      5,
                      "1m",
                      "volume",
                      "minute",
                  )
  
      test_sim_params = SimulationParameters(
          start_session=test_start_minute,
          end_session=test_end_minute,
          data_frequency="minute",
          trading_calendar=self.trading_calendar,
      )
  
      history_algorithm = self.create_algo(
          history_algo, sim_params=test_sim_params
      )
      assert_get_history_window_called(
          lambda: history_algorithm.run(), is_legacy=True
      )
      assert_get_history_window_called(
          lambda: bar_data.history(
              [self.asset1, self.asset2, self.asset3], "volume", 5, "1m"
          ),
          is_legacy=False,
      )
  
imports: import warnings
  from mock import patch
  import numpy
  import pandas
  from pandas.core.common import PerformanceWarning
  from zipline.finance.trading import SimulationParameters
  from zipline.testing import MockDailyBarReader, create_daily_df_for_asset, create_minute_df_for_asset, str_to_seconds
  from zipline.testing.fixtures import WithCreateBarData, WithMakeAlgo, ZiplineTestCase
  from zipline.zipline_warnings import ZiplineDeprecationWarning
label_desc: Use image node_id 7 for calling the TestAPIShim obj's underlying member method code with example usage: obj.test_old_new_data_api_paths() without return types