コード例 #1
0
    def test_should_smooth_the_compass_bearing(self):
        mock_bearing = PropertyMock(side_effect=[185.0,180])
        mock_compass = Mock()
        type(mock_compass).bearing = mock_bearing
        sensors = Sensors(StubGPS(),self.windsensor,mock_compass,self.mock_time,self.exchange,self.logger,DEFAULT_CONFIG)
        sensors._bearing = 190

        self.exchange.publish(Event(EventName.tick))
        self.exchange.publish(Event(EventName.tick))

        self.assertEqual(sensors.compass_heading_instant,((190.0 + 185.0)/2 + 180.0)/2)