def test_initialize_call_initialize(self, mock_initialize, mock_set_interval, mock_dp, mock_tr): simulator = Simulator(budget=7000, from_dash_to="201220.170000-201220.180000") simulator._make_tag = MagicMock(return_value="orange") simulator.interval = 0.1 simulator.initialize() self.assertEqual(simulator.need_init, False) mock_initialize.assert_called_once() mock_set_interval.assert_called_once_with(0.1) mock_dp.assert_called_once_with(end="2020-12-20T18:00:00", count=60) mock_tr.assert_called_once_with(end="2020-12-20T18:00:00", count=60, budget=7000) simulator._make_tag.assert_called_once() self.assertEqual(simulator.operator.tag, "orange")
def test_run_single_call_start_and_terminate(self): simulator = Simulator() simulator.start = MagicMock() simulator.initialize = MagicMock() simulator.terminate = MagicMock() simulator.operator = MagicMock() simulator.operator.state = "terminated" simulator.run_single() simulator.start.assert_called() simulator.initialize.assert_called() simulator.terminate.assert_called()