Ejemplo n.º 1
0
 def test_we_can_register_a_new_valid_device_and_it_gets_stored(self):
     response = self.client.post("/device/",
                                 data=json.dumps(dict(location="Mill Lane")),
                                 content_type="application/json")
     new_device = CameraDevice(**response.json)
     self.assertTrue(new_device.validate())
     print device_store.devices()
     print new_device.guid
     self.assertTrue(new_device.guid in device_store.devices())
Ejemplo n.º 2
0
 def test_we_can_post_an_event_for_an_existing_device(self):
     # Register a new device, then send an event down.
     response = self.client.post("/device/",
                                 data=json.dumps(dict(location="Mill Lane")),
                                 content_type="application/json")
     print self.client.application.url_map.converters
     new_device = CameraDevice(**response.json)
     assert new_device.validate()
     response = self.client.post("/device/event/{0}/".format(new_device.guid),
                                 data=json.dumps(dict(count=1)),
                                 content_type="application/json")
     self.assert_200(response)
     assert len(event_store) == 1
     self.assertEquals(response.json, {"status": "OK"})