def test_prev_event_given_time_now_after_data_raises_value_error(self): # Arrange news_filter = EconomicNewsEventFilter( currencies=["USD"], impacts=["HIGH"], news_data=self.news_data, ) # Act, Assert with pytest.raises(ValueError): news_filter.prev_event(datetime(2050, 1, 1, 1, 1, tzinfo=pytz.utc))
def test_prev_event_given_time_now_before_data_raises_value_error(self): # Arrange news_filter = EconomicNewsEventFilter( currencies=["USD"], impacts=["HIGH"], news_data=self.news_data, ) # Act, Assert with pytest.raises(ValueError): news_filter.prev_event(UNIX_EPOCH)
def test_prev_event_given_valid_date_returns_expected_news_event(self): # Arrange news_filter = EconomicNewsEventFilter(currencies=["USD"], impacts=['HIGH']) # Act event = news_filter.prev_event(datetime(2017, 8, 10, 15, 0, tzinfo=pytz.utc)) self.assertEqual(Timestamp("2017-08-04 12:30:00+0000", tz="UTC"), event.timestamp)
def test_prev_event_given_valid_date_returns_expected_news_event(self): # Arrange news_filter = EconomicNewsEventFilter( currencies=["USD"], impacts=["HIGH"], news_data=self.news_data, ) # Act event = news_filter.prev_event(datetime(2017, 8, 10, 15, 0, tzinfo=pytz.utc)) assert event.ts_event == 1501849800000000000
def test_next_event_given_valid_date_returns_expected_news_event(self): # Arrange news_filter = EconomicNewsEventFilter( currencies=["USD"], impacts=["HIGH"], news_data=self.news_data, ) # Act event = news_filter.prev_event( datetime(2015, 5, 10, 12, 0, tzinfo=pytz.utc)) self.assertEqual(1431088200000000000, event.ts_event_ns)
def test_next_event_given_valid_date_returns_expected_news_event(self): # Arrange news_filter = EconomicNewsEventFilter( currencies=["USD"], impacts=["HIGH"], news_data=self.news_data, ) # Act event = news_filter.prev_event(datetime(2015, 5, 10, 12, 0, tzinfo=pytz.utc)) self.assertEqual( pd.Timestamp("2015-05-08 12:30:00+0000", tz="UTC"), event.timestamp )