def setUp(self): self.logger = Mock() self.logger.error = Mock(side_effect=print_msg) self.servo = Mock() self.exchange = Exchange(self.logger) self.timer = StubTimer() TimeShift(self.exchange, self.timer.time)
def test_should_call_update_stats(self): stub_callback = StubTimer() sensors = Mock() Tracker(Mock(), sensors, stub_callback).track(300) stub_callback.signal_time_elapsed() sensors.update_averages.assert_called_once_with(None)
def test_should_log_current_position_callback_every_time_callback_fires( self): stub_callback = StubTimer() sensors = Mock() Tracker(Mock(), sensors, stub_callback).track(300) stub_callback.signal_time_elapsed() stub_callback.signal_time_elapsed() stub_callback.signal_time_elapsed() self.assertEqual(sensors.log_values.call_count, 3)
def test_should_log_welcome_message_and_column_headers(self): now = datetime.datetime.now() mock_logger = Mock() mock_sensors = Mock() Tracker(mock_logger, mock_sensors, StubTimer()).track(300) mock_logger.info.assert_has_calls([ call('Pi-Nav starting tracking ' + now.strftime("%Y-%m-%d")), call( 'latitude, longitute, +-lat, +-long, speed, track, +-speed, +-track, |, wind, avg wind, abs wind, |, comp, avg comp' ) ])
def setUp(self): self.mock_logger = Mock() self.mock_logger.error = Mock(side_effect=print_msg) self.exchange = Exchange(self.mock_logger) self.timer = StubTimer() self.timeshift = TimeShift(self.exchange, self.timer.time) self.event_source = EventSource(self.exchange, self.timer, self.mock_logger, {'tick interval': 0.2}) gps = FakeMovingGPS([ Position(10, 10), Position(11, 11), Position(12, 12), Position(13, 13) ]) self.navigator = Navigator(gps, Globe(), self.exchange, self.mock_logger, { 'min time to steer': 5, 'max time to steer': 20 })
def test_should_pass_interval_to_callback_timer(self): stub_callback = StubTimer() Tracker(Mock(), Mock(), stub_callback).track(300) self.assertEqual(stub_callback.seconds, 300)