def test_none_list(self): self.post(status=201, device_id="AMEI", entries=json.dumps( {"action": "upload_photo"})) self.assertEquals(LogEntry.query().count(), 1) entry = LogEntry.query().get() self.assertEquals(entry.action, "upload_photo") self.assertEquals(entry.quantity, 1) self.assertEquals(entry.device.string_id(), "AMEI") self.assertTrue(entry.user is None) self.assertEquals(entry.key.parent(), self._default_access)
def test_with_userd_list(self): self.post(status=201, user_id="custom_user_g+0001", entries=json.dumps( {"action": "start_app"})) self.assertEquals(LogEntry.query().count(), 1) entry = LogEntry.query().get() self.assertEquals(entry.action, "start_app") self.assertEquals(entry.quantity, 1) self.assertEquals(entry.user.string_id(), "custom_user_g+0001") self.assertTrue(entry.device is None) self.assertEquals(entry.key.parent(), self._default_access)
def test_user_and_device(self): self.post(status=201, user_id="custom_user_g+0004", device_id="Ameito192", entries=json.dumps([{"action": "start_app"}])) self.assertEquals(LogEntry.query().count(), 1) entry = LogEntry.query().get() self.assertEquals(entry.action, "start_app") self.assertEquals(entry.quantity, 1) self.assertEquals(entry.user.string_id(), "custom_user_g+0004") self.assertEquals(entry.device.string_id(), "Ameito192") self.assertEquals(entry.key.parent(), self._default_access)
def test_multiple(self): self.post(status=201, device_id="Meito", entries=json.dumps([ {"action": "upload_photo"}, {"action": "upload_photo"} ])) self.assertEquals(LogEntry.query().count(), 2) for entry in LogEntry.query(): self.assertEquals(entry.quantity, 1) self.assertEquals(entry.device.string_id(), "Meito") self.assertTrue(entry.user is None) self.assertEquals(entry.key.parent(), self._default_access)
def status_update(): jobID = request.form.get('jobID') if not jobID or jobID == '': return {'done': False, 'result': []} job_query = LogEntry.query(LogEntry.jobID==jobID) job_results = [] done = False for j in job_query: job_results.extend(j.record) j.key.delete() if j.crawlFinished == True: done = True return json.dumps({'result': job_results, 'done': done})