def test_frame_set_select_extract_face_rejected(self): with deepstar_path(): video_0001 = os.path.dirname(os.path.realpath(__file__)) + '/../../support/video_0001.mp4' # noqa shutil.copyfile(video_0001, VideoFile.path('video_0001.mp4')) VideoModel().insert('test', 'video_0001.mp4') DefaultVideoSelectExtractPlugin().video_select_extract(1) # noqa frame_model = FrameModel() frame_model.update(2, 1) frame_model.update(4, 1) with mock.patch.dict(os.environ, {'MODEL_LIST_LENGTH': '2'}): transform_set_id = MTCNNFrameSetSelectExtractPlugin().frame_set_select_extract(1, {}) # noqa self.assertEqual(transform_set_id, 1) # db result = TransformSetModel().select(1) self.assertEqual(result, (1, 'face', 1, None)) result = TransformModel().list(1) self.assertEqual(len(result), 3) t = list(result[0]) json.loads(t.pop(3)) self.assertEqual(t, [1, 1, 1, 0]) t = list(result[1]) json.loads(t.pop(3)) self.assertEqual(t, [2, 1, 3, 0]) t = list(result[2]) json.loads(t.pop(3)) self.assertEqual(t, [3, 1, 5, 0]) # files p1 = TransformSetSubDir.path(1) # transforms self.assertTrue(os.path.isfile(TransformFile.path(p1, 1, 'jpg'))) self.assertTrue(os.path.isfile(TransformFile.path(p1, 2, 'jpg'))) self.assertTrue(os.path.isfile(TransformFile.path(p1, 3, 'jpg')))
def put(self, frame_set_id, frame_id): frame_model = FrameModel() result = frame_model.update(frame_id, request.get_json()['rejected']) if result is False: abort(404) result = frame_model.select(frame_id) if result is None: abort(404) return jsonify(result)
def test_update(self): with deepstar_path(): VideoModel().insert('test1', 'test2') FrameSetModel().insert(1) frame_model = FrameModel() frame_model.insert(1, 0) result = frame_model.select(1) self.assertEqual(result, (1, 1, 0)) result = frame_model.update(1, 1) self.assertTrue(result) result = frame_model.select(1) self.assertEqual(result, (1, 1, 1))