예제 #1
0
 def test_update_sensor_raises_exception_when_sensor_is_invalid(self):
     # Arrange
     sensor = json.loads('{"bogus": "bogus"}')
     # Act
     with self.assertRaises(Exception) as context:
         update.update_sensor(self.config_file, self.config, sensor)
     # Assert
     expected = 'Missing sensor name'
     self.assertEqual(context.exception.message, expected)
예제 #2
0
 def test_update_sensor_raises_exception_when_sensor_is_invalid(self):
     # Arrange
     sensor = json.loads('{"bogus": "bogus"}')
     # Act
     with self.assertRaises(Exception) as context:
         update.update_sensor(self.config_file, self.config, sensor)
     # Assert
     expected = 'Missing sensor name'
     self.assertEqual(context.exception.message, expected)
예제 #3
0
 def test_update_sensor_merges_existing_section(self):
     # Arrange
     sensor = json.loads('{"name": "Start & finish", "hardware": '
                         '"RPI_REV1"}')
     # Act
     config = update.update_sensor(self.config_file, self.config, sensor)
     # Assert
     self.assertEqual(config['sensors'][0]['hardware'], 'RPI_REV1')
예제 #4
0
 def test_update_sensor_merges_existing_section(self):
     # Arrange
     sensor = json.loads('{"name": "Start & finish", "hardware": '
                         '"RPI_REV1"}')
     # Act
     config = update.update_sensor(self.config_file, self.config, sensor)
     # Assert
     self.assertEqual(config['sensors'][0]['hardware'], 'RPI_REV1')
예제 #5
0
파일: api.py 프로젝트: movermeyer/pi-time
 def update_sensor(self, sensor):
     config = update.update_sensor(self.config_file, self.config,
                                   sensor)
     if "sensors" in config:
         self.config = config
         self._publish("sensor_changed", config["sensors"])