示例#1
0
    def test_reading(self):

        #creating a Sensor object
        sensor = Sensor(node_id="A3 E5 2A 21")
        sensor.save()

        #creating a SensorLocation for that specific sensor
        sensor_location = SensorLocation(sensor_ref=sensor)
        sensor_location.save()

        Reading.create_from_udp(
            packet_timestamp=datetime.datetime(2015,
                                               1,
                                               1,
                                               15,
                                               11,
                                               17,
                                               tzinfo=timezone.utc),
            source_ip_address="10.11.12.13",
            message_counter=5,
            node_id="A3 E5 2A 21",
            decrypted_payload=bytes(
                b'{"@":"c2a1","+":5,"T|C16":124,"H|%":81,"O":1}'))

        self.assertEqual(1, Reading.objects.filter(value=81).count())
        self.assertEqual(3, Reading.objects.all().count())
示例#2
0
    def test_measurement(self):

	#creating a Sensor object
	sensor = Sensor(node_id = "A3 E5 2A 21")
	sensor.save()
	
	#creating a SensorLocation for that specific sensor
	sensor_location = SensorLocation(sensor_ref = sensor)
	sensor_location.save()

        Reading.create_from_udp(packet_timestamp=datetime.datetime(2015, 1, 1, 15, 11, 17, tzinfo=timezone.utc), source_ip_address="10.11.12.13", message_counter=5, node_id="A3 E5 2A 21", decrypted_payload=bytes(b'{"@":"c2a1","+":5,"T|C16":124,"H|%":81,"L":0}'))

	self.assertEqual(1, Measurement.objects.filter(sensor_location_ref__sensor_ref__node_id = "A3 E5 2A 21").count())
示例#3
0
    def test(self):
        sensor = Sensor(node_id='TEST1', created=datetime.datetime(2015, 1, 1, 15, 11, 17, tzinfo=timezone.utc), updated=datetime.datetime(2015, 1, 1, 15, 11, 17, tzinfo=timezone.utc))
        sensor.save()

        sensor_location_1 = SensorLocation(sensor_ref=sensor, aes_key="not me", created=datetime.datetime(2015, 1, 1, 15, 11, 17, tzinfo=timezone.utc), finish=datetime.datetime(2015, 1, 1, 15, 11, 18, tzinfo=timezone.utc))
        sensor_location_1.save()
        sensor_location_2 = SensorLocation(sensor_ref=sensor, aes_key="not me", created=datetime.datetime(2015, 1, 1, 15, 11, 19, tzinfo=timezone.utc), finish=datetime.datetime(2015, 2, 1, 15, 11, 35, tzinfo=timezone.utc))
        sensor_location_2.save()
        sensor_location_3 = SensorLocation(sensor_ref=sensor, aes_key="yes I'm the one", created=datetime.datetime(2016, 1, 1, 15, 11, 17, tzinfo=timezone.utc))
        sensor_location_3.save()

        partial_node_id = 'TE'

        returned_sensor = SensorQuery().get_sensor_from_partial_node_id(partial_node_id)
        self.assertEqual('TEST1', returned_sensor.node_id)
        sensor_location = SensorLocationQuery().get_current_sensor_location(returned_sensor)
        self.assertEqual("yes I'm the one", sensor_location.aes_key)
示例#4
0
 def test(self):
     partial_node_id = 'TE'
     sensor = Sensor(node_id='TEST1',
                     created=datetime.datetime(2015,
                                               1,
                                               1,
                                               15,
                                               11,
                                               17,
                                               tzinfo=timezone.utc),
                     updated=datetime.datetime(2015,
                                               1,
                                               1,
                                               15,
                                               11,
                                               17,
                                               tzinfo=timezone.utc))
     sensor.save()
     returned_sensor = SensorQuery().get_sensor_from_partial_node_id(
         partial_node_id)
     self.assertEqual(returned_sensor, sensor)
示例#5
0
    def sensor_test(self):
	sensor = Sensor(node_id = "A3 E5 2A 21")
	sensor.save()
	self.assertEqual(1, Sensor.objects.filter(node_id = "A3 E5 2A 21").count())
示例#6
0
 def test(self):
     partial_node_id = 'TE'
     sensor = Sensor(node_id='TEST1', created=datetime.datetime(2015, 1, 1, 15, 11, 17, tzinfo=timezone.utc), updated=datetime.datetime(2015, 1, 1, 15, 11, 17, tzinfo=timezone.utc))
     sensor.save()
     returned_sensor = SensorQuery().get_sensor_from_partial_node_id(partial_node_id)
     self.assertEqual(returned_sensor, sensor)
示例#7
0
 def sensor_test(self):
     sensor = Sensor(node_id="A3 E5 2A 21")
     sensor.save()
     self.assertEqual(1,
                      Sensor.objects.filter(node_id="A3 E5 2A 21").count())
示例#8
0
    def test(self):
        sensor = Sensor(node_id='TEST1',
                        created=datetime.datetime(2015,
                                                  1,
                                                  1,
                                                  15,
                                                  11,
                                                  17,
                                                  tzinfo=timezone.utc),
                        updated=datetime.datetime(2015,
                                                  1,
                                                  1,
                                                  15,
                                                  11,
                                                  17,
                                                  tzinfo=timezone.utc))
        sensor.save()

        sensor_location_1 = SensorLocation(
            sensor_ref=sensor,
            aes_key="not me",
            created=datetime.datetime(2015,
                                      1,
                                      1,
                                      15,
                                      11,
                                      17,
                                      tzinfo=timezone.utc),
            finish=datetime.datetime(2015,
                                     1,
                                     1,
                                     15,
                                     11,
                                     18,
                                     tzinfo=timezone.utc))
        sensor_location_1.save()
        sensor_location_2 = SensorLocation(
            sensor_ref=sensor,
            aes_key="not me",
            created=datetime.datetime(2015,
                                      1,
                                      1,
                                      15,
                                      11,
                                      19,
                                      tzinfo=timezone.utc),
            finish=datetime.datetime(2015,
                                     2,
                                     1,
                                     15,
                                     11,
                                     35,
                                     tzinfo=timezone.utc))
        sensor_location_2.save()
        sensor_location_3 = SensorLocation(sensor_ref=sensor,
                                           aes_key="yes I'm the one",
                                           created=datetime.datetime(
                                               2016,
                                               1,
                                               1,
                                               15,
                                               11,
                                               17,
                                               tzinfo=timezone.utc))
        sensor_location_3.save()

        partial_node_id = 'TE'

        returned_sensor = SensorQuery().get_sensor_from_partial_node_id(
            partial_node_id)
        self.assertEqual('TEST1', returned_sensor.node_id)
        sensor_location = SensorLocationQuery().get_current_sensor_location(
            returned_sensor)
        self.assertEqual("yes I'm the one", sensor_location.aes_key)