Exemplo n.º 1
0
    def setUp(self):
        self.set_application(tst_app)
        self.setup_testbed()
        self.init_datastore_stub()
        self.init_memcache_stub()
        self.init_taskqueue_stub()
        self.init_app_identity_stub()
        self.init_mail_stub()
        self.register_search_api_stub()
        self.init_urlfetch_stub()
        self.init_blobstore_stub()
        self.init_modules_stub()
        cloudstorage.set_default_retry_params(None)

        # Create enterprise, sensortype and sensor
        self.e = Enterprise.Create()
        self.e.Update(name="Test Ent", timezone="Africa/Nairobi")
        self.e.put()

        self.owner = User.Create(self.e, phone=OWNER_NUM, notify=False)
        self.owner.Update(name=OWNER_NAME, currency="KES")
        self.owner.put()

        self.spedometer = SensorType.Create(self.e)
        schema = {'speed': {'unit': 'kph'}, 'narrative': {'type': 'string'}}
        self.spedometer.Update(name="Spedometer", schema=json.dumps(schema))
        self.spedometer.put()

        self.vehicle_1 = Sensor.Create(self.e, TEST_SENSOR_ID,
                                       self.spedometer.key().id())
        self.vehicle_1.Update(sensortype_id=self.spedometer.key().id(),
                              name="Vehicle Sensor 1")
        self.vehicle_1.put()
Exemplo n.º 2
0
    def setUp(self):
        self.set_application(tst_app)
        self.setup_testbed()
        self.init_datastore_stub()
        self.init_memcache_stub()
        self.init_taskqueue_stub()
        self.register_search_api_stub()
        self.init_modules_stub()

        # Create enterprise, sensortype and sensor
        self.e = Enterprise.Create()
        self.e.Update(name="Test Ent", alias=E_ALIAS.upper())
        self.e.put()

        self.u = User.Create(self.e, phone=TEST_NUM, email=TEST_EMAIL)
        self.u.Update(password=PW, level=USER.ACCOUNT_ADMIN)
        self.u.put()

        self.st = SensorType.Create(self.e)

        self.st.Update(alias="geo",
                       schema=json.dumps({'location': {
                           'type': 'location'
                       }}))
        self.st.put()
Exemplo n.º 3
0
    def setUp(self):
        self.set_application(tst_app)
        self.setup_testbed()
        self.init_datastore_stub()
        self.init_memcache_stub()
        self.init_taskqueue_stub()
        self.init_mail_stub()
        self.register_search_api_stub()
        self.init_urlfetch_stub()
        self.init_modules_stub()

        # Create enterprise, sensortype and sensor
        self.e = Enterprise.Create()
        self.e.Update(name="Test Ent", timezone="Africa/Nairobi")
        self.e.put()

        self.owner = User.Create(self.e, phone=OWNER_NUM, notify=False)
        self.owner.Update(name=OWNER_NAME, currency="KES")
        self.owner.put()

        self.spedometer = SensorType.Create(self.e)
        schema = {
            'speed': {
                'unit': 'kph'
            },
            'bearing': {
                'unit': 'deg'
            },
            'location': {
                'unit': 'degrees'
            },
            'hard_braking': {
                'unit': 'boolean'
            }
        }
        self.spedometer.Update(name="Geo Sensor", schema=json.dumps(schema))
        self.spedometer.put()

        self.vehicle_1 = Sensor.Create(self.e, TEST_SENSOR_ID,
                                       self.spedometer.key().id())
        self.vehicle_1.Update(sensortype_id=self.spedometer.key().id(),
                              name="Vehicle Sensor 1",
                              contacts={"owner": self.owner.key().id()})
        self.vehicle_1.put()

        # Create alarm
        self.speeding_alarm = Rule.Create(self.e)
        self.speeding_alarm.Update(name="Speeding",
                                   sensortype_id=self.spedometer.key().id(),
                                   column="speed",
                                   trigger=RULE.CEILING,
                                   value2=80.0,
                                   alert_contacts=["owner"],
                                   alert_message=SPEEDING_ALERT_MESSAGE,
                                   duration=0)
        self.speeding_alarm.put()
Exemplo n.º 4
0
    def setUp(self):
        self.set_application(tst_app)
        self.setup_testbed()
        self.init_datastore_stub()
        self.init_memcache_stub()
        self.init_taskqueue_stub()
        self.register_search_api_stub()

        # Create enterprise, sensortype and sensor
        self.e = Enterprise.Create()
        self.e.Update(name="Test Ent")
        self.e.put()

        self.geosensor = SensorType.Create(self.e)
        schema = {
            'location': {
                'unit': 'deg',
                'label': "Location",
                'role': [COLUMN.LOCATION]
            },
            'ax': {},
            'ay': {
                'unit': 'm/s^2',
                'type': 'number'
            },
            'az': {
                'unit': 'm/s^2',
                'type': 'number'
            },
            'accel_mag': {
                'unit': 'm/2^2',
                'label': "Acceleration Magnitude",
                'calculation': "SQRT([ax]^2 + [ay]^2 + [az]^2)"
            }
        }
        self.geosensor.Update(name="Geo Sensor", schema=json.dumps(schema))
        self.geosensor.put()

        self.geosensor1 = Sensor.Create(self.e, TEST_SENSOR_ID,
                                        self.geosensor.key().id())
        self.geosensor1.Update(sensortype_id=self.geosensor.key().id(),
                               name="Geo Sensor 1")
        self.geosensor1.put()
Exemplo n.º 5
0
    def setUp(self):
        self.set_application(tst_app)
        self.setup_testbed()
        self.init_datastore_stub()
        self.init_memcache_stub()
        self.init_taskqueue_stub()
        self.init_mail_stub()
        self.register_search_api_stub()
        self.init_urlfetch_stub()
        self.init_modules_stub()

        # Create enterprise, sensortype and sensor
        self.e = Enterprise.Create()
        self.e.Update(name="Test Ent", timezone="Africa/Nairobi")
        self.e.put()

        self.owner = User.Create(self.e, phone=OWNER_NUM, notify=False)
        self.owner.Update(name=OWNER_NAME, currency="KES")
        self.owner.put()

        self.tracker = SensorType.Create(self.e)
        schema = {
            'bearing': {
                'unit': 'deg'
            },
            'location': {
                'unit': 'deg',
                'label': "Location",
                'role': [COLUMN.LOCATION],
                'type': 'latlng'
            }
        }
        self.tracker.Update(name="Geo Sensor", schema=json.dumps(schema))
        self.tracker.put()

        self.vehicle_1 = Sensor.Create(self.e, TEST_SENSOR_ID,
                                       self.tracker.key().id())
        self.vehicle_1.Update(sensortype_id=self.tracker.key().id(),
                              name="Vehicle Sensor 1",
                              contacts={"owner": self.owner.key().id()})
        self.vehicle_1.put()
    def setUp(self):
        self.set_application(tst_app)
        self.setup_testbed()
        self.init_datastore_stub()
        self.init_memcache_stub()
        self.init_taskqueue_stub()
        self.init_mail_stub()
        self.register_search_api_stub()
        self.init_urlfetch_stub()
        self.init_modules_stub()

        # Create enterprise, sensortype and sensor
        self.e = Enterprise.Create()
        self.e.Update(name="Test Ent", timezone="Africa/Nairobi")
        self.e.put()

        self.tracker = SensorType.Create(self.e)
        schema = {
            'speed': {
                'unit': 'kph'
            },
            'ign_on': {
                'unit': 'boolean'
            },
            'ign_off': {
                'unit': 'boolean'
            }

        }
        self.tracker.Update(name="Tracker Sensor", schema=json.dumps(schema))
        self.tracker.put()

        self.vehicle_1 = Sensor.Create(self.e, TEST_SENSOR_ID, self.tracker.key().id())
        self.vehicle_1.Update(
            sensortype_id=self.tracker.key().id(),
            name="Vehicle Sensor 1"
            )
        self.vehicle_1.put()

        # Create alarm
        self.ign_on_alarm = Rule.Create(self.e)
        self.ign_on_alarm.Update(
            name="Ignition On",
            sensortype_id=self.tracker.key().id(),
            column="ign_on",
            trigger=RULE.CEILING,
            value2=0,
            consecutive_limit=-1,
            duration=0)
        self.ign_on_alarm.put()
        self.ign_off_alarm = Rule.Create(self.e)
        self.ign_off_alarm.Update(
            name="Ignition Off",
            sensortype_id=self.tracker.key().id(),
            column="ign_off",
            trigger=RULE.CEILING,
            value2=0,
            consecutive_limit=-1,
            duration=0,
            spec=json.dumps({'processers': [
                {
                    'analysis_key_pattern': ANALYSIS_KEY_PATTERN,
                    'expr': '. + SINCE(LAST_ALARM(%d)) / 1000' % self.ign_on_alarm.key().id(),
                    'column': 'on_secs'
                }
            ]}))
        self.ign_off_alarm.put()