def test_zone_list_get_with_sensor_filter(self, api_root): excluded_zone = Zone(name='Test Zone Excluded', notes='Zone notes.', key=uuid4()) excluded_zone.save() excluded_sensor = Sensor(guid=uuid4(), name='Test Sensor Excluded', notes='Sensor notes.', zone=excluded_zone, min_value=20, max_value=25, min_value_operator='>=', max_value_operator='<=', state=True, state_last_change_date=datetime.utcnow()) excluded_sensor.save() suffix = 'zones/?sensor_ids={}&format=json'.format(self.sensor.id) response = requests.get(api_root + suffix) data = response.json() assert len(data) > 0 excluded_zone_json = [ x for x in data if x['id'] == str(excluded_zone.id) ] assert len(excluded_zone_json) == 0 excluded_sensor.delete() excluded_zone.delete() zone_json = [x for x in data if int(x['id']) == self.zone.id][0] self._compare_zone_json(self.zone, zone_json)
def test_zone_list_get_with_sensor_filter(self, api_root): excluded_zone = Zone( name='Test Zone Excluded', notes='Zone notes.', key=uuid4() ) excluded_zone.save() excluded_sensor = Sensor( guid=uuid4(), name='Test Sensor Excluded', notes='Sensor notes.', zone=excluded_zone, min_value=20, max_value=25, min_value_operator='>=', max_value_operator='<=', state=True, state_last_change_date=datetime.utcnow() ) excluded_sensor.save() suffix = 'zones/?sensor_ids={}&format=json'.format(self.sensor.id) response = requests.get(api_root + suffix) data = response.json() assert len(data) > 0 excluded_zone_json = [x for x in data if x['id'] == str(excluded_zone.id)] assert len(excluded_zone_json) == 0 excluded_sensor.delete() excluded_zone.delete() zone_json = [x for x in data if int(x['id']) == self.zone.id][0] self._compare_zone_json(self.zone, zone_json)
def test_sensor_data_list_get_with_sensor_filter(self, api_root): excluded_sensor = Sensor( guid=uuid4(), name='Test Sensor Excluded', notes='Sensor notes.', zone=self.zone, min_value=20, max_value=25, min_value_operator='>=', max_value_operator='<=', state=True, state_last_change_date=datetime.utcnow() ) excluded_sensor.save() excluded_data = SensorData( sensor=excluded_sensor, datetime=datetime.utcnow(), value=22, state=True, state_changed=False ) excluded_data.save() suffix = 'data/?sensor_ids={}&format=json'.format(self.sensor.id) response = requests.get(api_root + suffix) data = response.json() assert len(data) > 0 excluded_data_json = [x for x in data if x['id'] == str(excluded_data.id)] assert len(excluded_data_json) == 0 excluded_data.delete() excluded_sensor.delete() for i in range(3): data_json = [x for x in data if int(x['id']) == self.data[i].id][0] self._compare_sensor_data_json(self.data[i], data_json)
def test_sensor_data_list_get_with_sensor_filter(self, api_root): excluded_sensor = Sensor(guid=uuid4(), name='Test Sensor Excluded', notes='Sensor notes.', zone=self.zone, min_value=20, max_value=25, min_value_operator='>=', max_value_operator='<=', state=True, state_last_change_date=datetime.utcnow()) excluded_sensor.save() excluded_data = SensorData(sensor=excluded_sensor, datetime=datetime.utcnow(), value=22, state=True, state_changed=False) excluded_data.save() suffix = 'data/?sensor_ids={}&format=json'.format(self.sensor.id) response = requests.get(api_root + suffix) data = response.json() assert len(data) > 0 excluded_data_json = [ x for x in data if x['id'] == str(excluded_data.id) ] assert len(excluded_data_json) == 0 excluded_data.delete() excluded_sensor.delete() for i in range(3): data_json = [x for x in data if int(x['id']) == self.data[i].id][0] self._compare_sensor_data_json(self.data[i], data_json)