def test(self): truncateTable('incoming_image') dao = IncomingImageDAO(defaultConfigPath()) self.assertIsNotNone(dao) # test with empty table self.assertIsNone(dao.getNextImage(True)) self.assertIsNone(dao.getNextImage(False)) model = incoming_image() model.time_stamp = 1547453775.2 model.focal_length = 16.0 model.image_path = '/im/a/totally/real/path/i/swear.jpg' model.manual_tap = False model.autonomous_tap = False resultingId = dao.addImage(model) self.assertNotEqual(resultingId, -1) # identical timestamps should make no difference model.focal_length = 16.0 model.image_path = '/im/a/totally/real/path/2/i/swear.jpg' resultingId2 = dao.addImage(model) self.assertNotEqual(resultingId2, -1) resultModel = dao.getNextImage(True) self.assertIsNotNone(resultModel) self.assertEqual(resultModel.image_id, resultingId) self.assertTrue(resultModel.manual_tap) self.assertFalse(resultModel.autonomous_tap) resultModel = dao.getNextImage(True) self.assertIsNotNone(resultModel) self.assertEqual(resultModel.image_id, resultingId2) self.assertTrue(resultModel.manual_tap) self.assertFalse(resultModel.autonomous_tap) resultModel = dao.getNextImage(False) self.assertIsNotNone(resultModel) self.assertEqual(resultModel.image_id, resultingId) self.assertTrue(resultModel.manual_tap) self.assertTrue(resultModel.autonomous_tap) resultModel = dao.getNextImage(True) self.assertIsNone(resultModel) resultModel = dao.getNextImage(False) self.assertIsNotNone(resultModel) self.assertEqual(resultModel.image_id, resultingId2) self.assertTrue(resultModel.manual_tap) self.assertTrue(resultModel.autonomous_tap) resultModel = dao.getNextImage(False) self.assertIsNone(resultModel)
def get(self): # startTime = time.time() # Input Validation:: manual = checkXManual(request) # Get Content dao = IncomingImageDAO(defaultConfigPath()) image = dao.getNextImage(manual) # response validation if image is None: return {'message': 'Failed to locate untapped image'}, 404 # print("Request fulfillment: {}".format(time.time()-startTime)) return rawImageSender(image.image_id, image.image_path)