def test_checks_should_trigger(self): class CountingRule(Always): count = 0 def should_trigger(self, dt): CountingRule.count += 1 return True for r in [CountingRule] * 5: self.em.add_event(Event(r())) self.em.handle_data(None, None, datetime.datetime.now()) assert CountingRule.count == 5
def test_checks_should_trigger(self): class CountingRule(Always): count = 0 def should_trigger(self, dt): CountingRule.count += 1 return True for r in [CountingRule] * 5: self.em.add_event( Event(r(), lambda context, data: None, check_args=False)) self.em.handle_data(None, None, datetime.datetime.now()) self.assertEqual(CountingRule.count, 5)
def test_checks_should_trigger(self): class CountingRule(Always): count = 0 def should_trigger(self, dt, env): CountingRule.count += 1 return True for r in [CountingRule] * 5: self.em.add_event(Event(r(), lambda context, data: None)) mock_algo_class = namedtuple('FakeAlgo', ['trading_environment']) mock_algo = mock_algo_class(trading_environment="fake_env") self.em.handle_data(mock_algo, None, datetime.datetime.now()) self.assertEqual(CountingRule.count, 5)
def setUp(self): self.em = EventManager() self.event1 = Event(Always(), lambda context, data: None) self.event2 = Event(Always(), lambda context, data: None)
def setUp(self): self.em = EventManager() self.event1 = Event(Always()) self.event2 = Event(Always())
def set_event_manager(request): request.cls.em = EventManager() request.cls.event1 = Event(Always()) request.cls.event2 = Event(Always())