Пример #1
0
    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))
Пример #2
0
    def test_insert(self):
        with deepstar_path():
            VideoModel().insert('test1', 'test2')

            FrameSetModel().insert(1)

            frame_model = FrameModel()
            frame_id = frame_model.insert(1, 0)
            self.assertEqual(frame_id, 1)

            result = frame_model.select(1)
            self.assertEqual(result, (1, 1, 0))
Пример #3
0
            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)
Пример #4
0
    def test_delete_one(self):
        with deepstar_path():
            with mock.patch.dict(os.environ, {'DEBUG_LEVEL': '0'}):
                route_handler = VideoCommandLineRouteHandler()

                video_0001 = os.path.dirname(os.path.realpath(__file__)) + '/../../support/video_0001.mp4'  # noqa

                route_handler.insert_file(video_0001)

                route_handler.select_extract([1])

            # files
            self.assertTrue(os.path.exists(FrameSetSubDir.path(1)))

            # db
            frame_set_model = FrameSetModel()

            self.assertIsNotNone(frame_set_model.select(1))

            frame_model = FrameModel()

            self.assertIsNotNone(frame_model.select(1))
            self.assertIsNotNone(frame_model.select(2))
            self.assertIsNotNone(frame_model.select(3))
            self.assertIsNotNone(frame_model.select(4))
            self.assertIsNotNone(frame_model.select(5))

            args = ['main.py', 'delete', 'frame_sets', '1']
            opts = {}

            route_handler = FrameSetCommandLineRouteHandler()

            try:
                sys.stdout = StringIO()
                route_handler.handle(args, opts)
                actual = sys.stdout.getvalue().strip()
            finally:
                sys.stdout = sys.__stdout__

            # stdout
            self.assertEqual(actual, 'Frame set 1 was successfully deleted')

            # db
            self.assertIsNone(frame_set_model.select(1))

            self.assertIsNone(frame_model.select(1))
            self.assertIsNone(frame_model.select(2))
            self.assertIsNone(frame_model.select(3))
            self.assertIsNone(frame_model.select(4))
            self.assertIsNone(frame_model.select(5))

            # files
            self.assertFalse(os.path.exists(FrameSetSubDir.path(1)))