def test_reading_creation(self): res = self.client.post('/readings', data=self.readings1) res = self.client.post('/readings', data=self.readings2) self.assertEquals(res.status_code, 201) self.assertFalse(Sensor.get("sensor1") is None) self.assertFalse(Sensor.get("sensor2") is None) self.assertTrue(len(Reading.get_all()) is 5)
def test_reading_creation(self): res = self.client.post('/readings', data=self.readings_1) self.assertEqual( res.data, '[\n {\n "calibration": true, \n "height": 0.94, \n "lat": -7.918233, \n "lat_lon_sd": 15.0, \n "lon": -33.412813, \n "sample_count": 100, \n "sensor_id": "sensor1", \n "time": 111.11, \n "uncal_pressure": 103242.0, \n "uncal_pressure_sd": 38.5, \n "uncal_temperature": 290.23, \n "uncal_temperature_sd": 1.2\n }, \n {\n "calibration": false, \n "height": 0.95, \n "lat": -7.918234, \n "lat_lon_sd": 16.0, \n "lon": -33.412812, \n "sample_count": 100, \n "sensor_id": "sensor1", \n "time": 222.22, \n "uncal_pressure": 103243.0, \n "uncal_pressure_sd": 38.6, \n "uncal_temperature": 290.24, \n "uncal_temperature_sd": 1.3\n }\n]\n' ) res = self.client.post('/readings', data=self.readings_2) self.assertEqual( res.data, '[\n {\n "calibration": true, \n "height": 0.96, \n "lat": -7.918235, \n "lat_lon_sd": 17.0, \n "lon": -33.412815, \n "sample_count": 100, \n "sensor_id": "sensor2", \n "time": 111.11, \n "uncal_pressure": 103247.0, \n "uncal_pressure_sd": 38.7, \n "uncal_temperature": 290.27, \n "uncal_temperature_sd": 1.7\n }, \n {\n "calibration": false, \n "height": 0.98, \n "lat": -7.918238, \n "lat_lon_sd": 18.0, \n "lon": -33.412818, \n "sample_count": 100, \n "sensor_id": "sensor2", \n "time": 222.22, \n "uncal_pressure": 103248.0, \n "uncal_pressure_sd": 38.8, \n "uncal_temperature": 290.28, \n "uncal_temperature_sd": 1.8\n }, \n {\n "calibration": false, \n "height": 0.99, \n "lat": -7.918239, \n "lat_lon_sd": 19.0, \n "lon": -33.412819, \n "sample_count": 100, \n "sensor_id": "sensor2", \n "time": 333.33, \n "uncal_pressure": 103249.0, \n "uncal_pressure_sd": 38.9, \n "uncal_temperature": 290.29, \n "uncal_temperature_sd": 1.9\n }\n]\n' ) self.assertEquals(res.status_code, 201) self.assertFalse(Sensor.get("sensor1") is None) self.assertFalse(Sensor.get("sensor2") is None) self.assertTrue(len(Reading.get_all()) is 5)
def test_sensor_creation(self): res = self.client.post('/sensors', data=self.sensor_fixed) self.assertEqual(res.status_code, 201) self.assertIn('fixed 1', str(res.data)) self.assertFalse(Sensor.get("fixed 1") is None)