Example #1
0
    def test_transform_set_select_merge_overlay_rejected(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])

                route_handler = FrameSetCommandLineRouteHandler()

                route_handler.select_extract([1], 'transform_set', {})
                route_handler.select_extract([1], 'transform_set', {})

                transform_model = TransformModel()

                transform_model.update(1, rejected=1)
                transform_model.update(10, rejected=1)

            OverlayTransformSetSelectMergePlugin().transform_set_select_merge(
                [1, 2], {
                    'x1': '0',
                    'y1': '0'
                })  # noqa

            # db
            result = TransformSetModel().select(3)
            self.assertEqual(result, (3, 'overlay', None, None))

            result = TransformModel().list(3)
            self.assertEqual(len(result), 4)
            self.assertEqual(result[0], (11, 3, None, None, 0))
            self.assertEqual(result[1], (12, 3, None, None, 0))
            self.assertEqual(result[2], (13, 3, None, None, 0))
            self.assertEqual(result[3], (14, 3, None, None, 0))

            # files
            p1 = TransformSetSubDir.path(3)

            # transforms
            self.assertIsInstance(cv2.imread(TransformFile.path(p1, 11,
                                                                'jpg')),
                                  np.ndarray)  # noqa
            self.assertIsInstance(cv2.imread(TransformFile.path(p1, 12,
                                                                'jpg')),
                                  np.ndarray)  # noqa
            self.assertIsInstance(cv2.imread(TransformFile.path(p1, 13,
                                                                'jpg')),
                                  np.ndarray)  # noqa
            self.assertIsInstance(cv2.imread(TransformFile.path(p1, 14,
                                                                'jpg')),
                                  np.ndarray)  # noqa
    def test_transform_set_select_extract_crop(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])

                FrameSetCommandLineRouteHandler().select_extract(
                    [1], 'transform_set', {})  # noqa

            CropTransformSetSelectExtractPlugin().transform_set_select_extract(
                1, {
                    'x1': '0',
                    'y1': '0',
                    'x2': '50',
                    'y2': '50'
                })  # noqa

            # db
            result = TransformSetModel().select(2)
            self.assertEqual(result, (2, 'crop', 1, 1))

            result = TransformModel().list(2)
            self.assertEqual(len(result), 5)
            self.assertEqual(result[0], (6, 2, 1, None, 0))
            self.assertEqual(result[1], (7, 2, 2, None, 0))
            self.assertEqual(result[2], (8, 2, 3, None, 0))
            self.assertEqual(result[3], (9, 2, 4, None, 0))
            self.assertEqual(result[4], (10, 2, 5, None, 0))

            # files
            p1 = TransformSetSubDir.path(2)

            # transforms
            self.assertEqual(
                cv2.imread(TransformFile.path(p1, 6, 'jpg')).shape[:2],
                (50, 50))  # noqa
            self.assertEqual(
                cv2.imread(TransformFile.path(p1, 7, 'jpg')).shape[:2],
                (50, 50))  # noqa
            self.assertEqual(
                cv2.imread(TransformFile.path(p1, 8, 'jpg')).shape[:2],
                (50, 50))  # noqa
            self.assertEqual(
                cv2.imread(TransformFile.path(p1, 9, 'jpg')).shape[:2],
                (50, 50))  # noqa
            self.assertEqual(
                cv2.imread(TransformFile.path(p1, 10, 'jpg')).shape[:2],
                (50, 50))  # noqa
Example #3
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)))
    def test_transform_set_select_merge_overlay_image(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])

                route_handler = FrameSetCommandLineRouteHandler()

                route_handler.select_extract([1], 'transform_set', {})

            image_0007 = os.path.dirname(os.path.realpath(
                __file__)) + '/../../support/image_0007.png'  # noqa

            OverlayImageTransformSetSelectMergePlugin(
            ).transform_set_select_merge([1], {
                'image-path': image_0007,
                'x1': '0',
                'y1': '0'
            })  # noqa

            # db
            result = TransformSetModel().select(2)
            self.assertEqual(result, (2, 'overlay_image', None, None))

            result = TransformModel().list(2)
            self.assertEqual(len(result), 5)
            self.assertEqual(result[0], (6, 2, None, None, 0))
            self.assertEqual(result[1], (7, 2, None, None, 0))
            self.assertEqual(result[2], (8, 2, None, None, 0))
            self.assertEqual(result[3], (9, 2, None, None, 0))
            self.assertEqual(result[4], (10, 2, None, None, 0))

            # files
            p1 = TransformSetSubDir.path(2)

            # transforms
            self.assertIsInstance(cv2.imread(TransformFile.path(p1, 6, 'jpg')),
                                  np.ndarray)  # noqa
            self.assertIsInstance(cv2.imread(TransformFile.path(p1, 7, 'jpg')),
                                  np.ndarray)  # noqa
            self.assertIsInstance(cv2.imread(TransformFile.path(p1, 8, 'jpg')),
                                  np.ndarray)  # noqa
            self.assertIsInstance(cv2.imread(TransformFile.path(p1, 9, 'jpg')),
                                  np.ndarray)  # noqa
            self.assertIsInstance(cv2.imread(TransformFile.path(p1, 10,
                                                                'jpg')),
                                  np.ndarray)  # noqa
Example #5
0
    def test_insert_images_fails_due_to_isdir_fails(self):
        with deepstar_path():
            args = ['main.py', 'insert', 'frame_sets', 'images', 'test']
            opts = {}

            with self.assertRaises(CommandLineRouteHandlerError):
                try:
                    FrameSetCommandLineRouteHandler().handle(args, opts)
                except CommandLineRouteHandlerError as e:
                    self.assertEqual(e.message, 'The path at test is not a directory')  # noqa

                    raise e
Example #6
0
    def test_select_export_dir_fails_to_select_a_frame_set(self):
        with deepstar_path():
            args = ['main.py', 'select', 'frame_sets', '1', 'export', 'dir', 'test']  # noqa
            opts = {}

            with self.assertRaises(CommandLineRouteHandlerError):
                try:
                    FrameSetCommandLineRouteHandler().handle(args, opts)
                except CommandLineRouteHandlerError as e:
                    self.assertEqual(e.message, 'Frame set with ID 00000001 not found')  # noqa

                    raise e
Example #7
0
    def test_select_extract_transform_set(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])

            args = ['main.py', 'select', 'frame_sets', '1', 'extract', 'transform_set']  # noqa
            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, 'transform_set_id=1, name=transform_set, fk_frame_sets=1, fk_prev_transform_sets=None')  # noqa

            # db
            result = TransformSetModel().select(1)
            self.assertEqual(result, (1, 'transform_set', 1, None))

            result = TransformModel().list(1)
            self.assertEqual(len(result), 5)
            self.assertEqual(result[0], (1, 1, 1, None, 0))
            self.assertEqual(result[1], (2, 1, 2, None, 0))
            self.assertEqual(result[2], (3, 1, 3, None, 0))
            self.assertEqual(result[3], (4, 1, 4, None, 0))
            self.assertEqual(result[4], (5, 1, 5, None, 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')))
            self.assertTrue(os.path.isfile(TransformFile.path(p1, 4, 'jpg')))
            self.assertTrue(os.path.isfile(TransformFile.path(p1, 5, 'jpg')))
Example #8
0
    def test_transform_set_select_merge_fade(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])

                route_handler = FrameSetCommandLineRouteHandler()

                route_handler.select_extract([1], 'transform_set', {})
                route_handler.select_extract([1], 'transform_set', {})

            FadeTransformSetSelectMergePlugin().transform_set_select_merge([1, 2], {'frame-count': '2'})  # noqa

            # db
            result = TransformSetModel().select(3)
            self.assertEqual(result, (3, 'fade', None, None))

            result = TransformModel().list(3)
            self.assertEqual(len(result), 8)
            self.assertEqual(result[0], (11, 3, 1, None, 0))
            self.assertEqual(result[1], (12, 3, 2, None, 0))
            self.assertEqual(result[2], (13, 3, 3, None, 0))
            self.assertEqual(result[3], (14, 3, None, None, 0))
            self.assertEqual(result[4], (15, 3, None, None, 0))
            self.assertEqual(result[5], (16, 3, 3, None, 0))
            self.assertEqual(result[6], (17, 3, 4, None, 0))
            self.assertEqual(result[7], (18, 3, 5, None, 0))

            # files
            p1 = TransformSetSubDir.path(3)

            # transforms
            self.assertIsInstance(cv2.imread(TransformFile.path(p1, 11, 'jpg')), np.ndarray)  # noqa
            self.assertIsInstance(cv2.imread(TransformFile.path(p1, 12, 'jpg')), np.ndarray)  # noqa
            self.assertIsInstance(cv2.imread(TransformFile.path(p1, 13, 'jpg')), np.ndarray)  # noqa
            self.assertIsInstance(cv2.imread(TransformFile.path(p1, 14, 'jpg')), np.ndarray)  # noqa
            self.assertIsInstance(cv2.imread(TransformFile.path(p1, 15, 'jpg')), np.ndarray)  # noqa
            self.assertIsInstance(cv2.imread(TransformFile.path(p1, 16, 'jpg')), np.ndarray)  # noqa
            self.assertIsInstance(cv2.imread(TransformFile.path(p1, 17, 'jpg')), np.ndarray)  # noqa
            self.assertIsInstance(cv2.imread(TransformFile.path(p1, 18, 'jpg')), np.ndarray)  # noqa
Example #9
0
    def test_transform_set_select_extract_adjust_color_rejected(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])

                FrameSetCommandLineRouteHandler().select_extract(
                    [1], 'transform_set', {})  # noqa

                TransformModel().update(5, rejected=1)

            AdjustColorTransformSetSelectExtractPlugin(
            ).transform_set_select_extract(1, {
                'r': '+10',
                'g': '-10',
                'b': '+10'
            })  # noqa

            # db
            result = TransformSetModel().select(2)
            self.assertEqual(result, (2, 'adjust_color', 1, 1))

            result = TransformModel().list(2)
            self.assertEqual(len(result), 4)
            self.assertEqual(result[0], (6, 2, 1, None, 0))
            self.assertEqual(result[1], (7, 2, 2, None, 0))
            self.assertEqual(result[2], (8, 2, 3, None, 0))
            self.assertEqual(result[3], (9, 2, 4, None, 0))

            # files
            p1 = TransformSetSubDir.path(2)

            # transforms
            self.assertTrue(os.path.isfile(TransformFile.path(p1, 6, 'jpg')))
            self.assertTrue(os.path.isfile(TransformFile.path(p1, 7, 'jpg')))
            self.assertTrue(os.path.isfile(TransformFile.path(p1, 8, 'jpg')))
            self.assertTrue(os.path.isfile(TransformFile.path(p1, 9, 'jpg')))
Example #10
0
    def test_select_extract_fails_to_get_a_plugin(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])

            args = ['main.py', 'select', 'frame_sets', '1', 'extract', 'test']
            opts = {}

            with self.assertRaises(CommandLineRouteHandlerError):
                try:
                    FrameSetCommandLineRouteHandler().handle(args, opts)
                except CommandLineRouteHandlerError as e:
                    self.assertEqual(e.message, "'test' is not a valid frame set extraction plugin name")  # noqa

                    raise e
Example #11
0
    def test_select_extract_many(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.insert_file(video_0001)
                route_handler.insert_file(video_0001)

                route_handler.select_extract([1, 2, 3])

            class TestPlugin:
                def frame_set_select_extract(self, frame_set_id, opts):
                    return TransformSetModel().insert('test', frame_set_id, None)  # noqa

            args = ['main.py', 'select', 'frame_sets', '1-2,3', 'extract', 'test']  # noqa
            opts = {}

            route_handler = FrameSetCommandLineRouteHandler()

            try:
                sys.stdout = StringIO()
                with mock.patch.dict(Plugin._map, {'frame_set_select_extract': {'test': TestPlugin}}):  # noqa
                    route_handler.handle(args, opts)
                actual = sys.stdout.getvalue().strip()
            finally:
                sys.stdout = sys.__stdout__

            # stdout
            expected = 'transform_set_id=1, name=test, fk_frame_sets=1, ' \
                       'fk_prev_transform_sets=None\n' \
                       'transform_set_id=2, name=test, fk_frame_sets=2, ' \
                       'fk_prev_transform_sets=None\n' \
                       'transform_set_id=3, name=test, fk_frame_sets=3, ' \
                       'fk_prev_transform_sets=None'

            self.assertEqual(actual, expected)
    def test_transform_set_select_extract_slice(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])

                FrameSetCommandLineRouteHandler().select_extract(
                    [1], 'transform_set', {})  # noqa

            SliceTransformSetSelectExtractPlugin(
            ).transform_set_select_extract(1, {
                'start': '2',
                'end': '4'
            })  # noqa

            # db
            result = TransformSetModel().select(2)
            self.assertEqual(result, (2, 'slice', 1, 1))

            result = TransformModel().list(2)
            self.assertEqual(len(result), 3)
            self.assertEqual(result[0], (6, 2, 2, None, 0))
            self.assertEqual(result[1], (7, 2, 3, None, 0))
            self.assertEqual(result[2], (8, 2, 4, None, 0))

            # files
            p1 = TransformSetSubDir.path(2)

            # transforms
            self.assertTrue(os.path.isfile(TransformFile.path(p1, 6, 'jpg')))
            self.assertTrue(os.path.isfile(TransformFile.path(p1, 7, 'jpg')))
            self.assertTrue(os.path.isfile(TransformFile.path(p1, 8, 'jpg')))
Example #13
0
    def test_select_export_dir_one_rejected(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])

                FrameModel().update(5, rejected=1)

            tmpdir = os.environ['DEEPSTAR_PATH'] + '/test'

            os.mkdir(tmpdir)

            args = ['main.py', 'select', 'frame_sets', '1', 'export', 'dir', tmpdir]  # noqa
            opts = {}

            route_handler = FrameSetCommandLineRouteHandler()

            try:
                sys.stdout = StringIO()
                with mock.patch.dict(os.environ, {'MODEL_LIST_LENGTH': '2'}):
                    route_handler.handle(args, opts)
                actual = sys.stdout.getvalue().strip()
            finally:
                sys.stdout = sys.__stdout__

            # stdout
            self.assertEqual(actual, f'4 frames were successfully exported to {tmpdir}')  # noqa

            # frames
            self.assertTrue(os.path.isfile(FrameFile.path(tmpdir, 1, 'jpg')))  # noqa
            self.assertTrue(os.path.isfile(FrameFile.path(tmpdir, 2, 'jpg')))  # noqa
            self.assertTrue(os.path.isfile(FrameFile.path(tmpdir, 3, 'jpg')))  # noqa
            self.assertTrue(os.path.isfile(FrameFile.path(tmpdir, 4, 'jpg')))  # noqa
Example #14
0
    def test_transform_set_select_merge_fade_fails_due_to_missing_required_option(self):  # noqa
        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])

                route_handler = FrameSetCommandLineRouteHandler()

                route_handler.select_extract([1], 'transform_set', {})
                route_handler.select_extract([1], 'transform_set', {})

            with self.assertRaises(ValueError):
                try:
                    FadeTransformSetSelectMergePlugin().transform_set_select_merge([1, 2], {})  # noqa
                except ValueError as e:
                    self.assertEqual(str(e), 'The frame-count option is required but was not supplied')  # noqa

                    raise e
Example #15
0
    def test_transform_set_select_merge_fade_fails_due_to_transform_set_count_less_than_frame_count(self):  # noqa
        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])

                route_handler = FrameSetCommandLineRouteHandler()

                route_handler.select_extract([1], 'transform_set', {})
                route_handler.select_extract([1], 'transform_set', {})

            with self.assertRaises(ValueError):
                try:
                    FadeTransformSetSelectMergePlugin().transform_set_select_merge([1, 2], {'frame-count': '6'})  # noqa
                except ValueError as e:
                    self.assertEqual(str(e), 'Both transform sets must be greater than frame count')  # noqa

                    raise e
Example #16
0
    def test_transform_set_select_merge_fade_fails_due_to_frame_counts_not_equal(
            self):  # noqa
        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
                video_0003 = os.path.dirname(os.path.realpath(
                    __file__)) + '/../../support/video_0003.mp4'  # noqa

                route_handler.insert_file(video_0001)
                route_handler.insert_file(video_0003)

                route_handler.select_extract([1])
                route_handler.select_extract([2])

                route_handler = FrameSetCommandLineRouteHandler()

                route_handler.select_extract([1], 'transform_set', {})
                route_handler.select_extract([2], 'transform_set', {})

            with self.assertRaises(ValueError):
                try:
                    OverlayTransformSetSelectMergePlugin(
                    ).transform_set_select_merge([1, 2], {
                        'x1': '0',
                        'y1': '0'
                    })  # noqa
                except ValueError as e:
                    self.assertEqual(str(
                        e
                    ), 'Both transform sets must have the same number of non-rejected transforms (be the same length)'
                                     )  # noqa

                    raise e
Example #17
0
    def test_select_merge_rejected(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.insert_file(video_0001)
                route_handler.insert_file(video_0001)

                route_handler.select_extract([1, 2, 3])

                FrameModel().update(15, rejected=1)

            args = ['main.py', 'select', 'frame_sets', '1-2,3', 'merge']
            opts = {}

            route_handler = FrameSetCommandLineRouteHandler()

            try:
                sys.stdout = StringIO()
                with mock.patch.dict(os.environ, {'MODEL_LIST_LENGTH': '4'}):
                    route_handler.handle(args, opts)
                actual = sys.stdout.getvalue().strip()
            finally:
                sys.stdout = sys.__stdout__

            # stdout
            self.assertEqual(actual, 'frame_set_id=4, fk_videos=None')

            # db
            result = FrameSetModel().select(4)
            self.assertEqual(result, (4, None))

            result = FrameModel().list(4)
            self.assertEqual(len(result), 14)
            self.assertEqual(result[0], (16, 4, 0))
            self.assertEqual(result[1], (17, 4, 0))
            self.assertEqual(result[2], (18, 4, 0))
            self.assertEqual(result[3], (19, 4, 0))
            self.assertEqual(result[4], (20, 4, 0))
            self.assertEqual(result[5], (21, 4, 0))
            self.assertEqual(result[6], (22, 4, 0))
            self.assertEqual(result[7], (23, 4, 0))
            self.assertEqual(result[8], (24, 4, 0))
            self.assertEqual(result[9], (25, 4, 0))
            self.assertEqual(result[10], (26, 4, 0))
            self.assertEqual(result[11], (27, 4, 0))
            self.assertEqual(result[12], (28, 4, 0))
            self.assertEqual(result[13], (29, 4, 0))

            # files
            p1 = FrameSetSubDir.path(4)

            # frames
            self.assertTrue(os.path.isfile(FrameFile.path(p1, 16, 'jpg')))
            self.assertTrue(os.path.isfile(FrameFile.path(p1, 17, 'jpg')))
            self.assertTrue(os.path.isfile(FrameFile.path(p1, 18, 'jpg')))
            self.assertTrue(os.path.isfile(FrameFile.path(p1, 19, 'jpg')))
            self.assertTrue(os.path.isfile(FrameFile.path(p1, 20, 'jpg')))
            self.assertTrue(os.path.isfile(FrameFile.path(p1, 21, 'jpg')))
            self.assertTrue(os.path.isfile(FrameFile.path(p1, 22, 'jpg')))
            self.assertTrue(os.path.isfile(FrameFile.path(p1, 23, 'jpg')))
            self.assertTrue(os.path.isfile(FrameFile.path(p1, 24, 'jpg')))
            self.assertTrue(os.path.isfile(FrameFile.path(p1, 25, 'jpg')))
            self.assertTrue(os.path.isfile(FrameFile.path(p1, 26, 'jpg')))
            self.assertTrue(os.path.isfile(FrameFile.path(p1, 27, 'jpg')))
            self.assertTrue(os.path.isfile(FrameFile.path(p1, 28, 'jpg')))
            self.assertTrue(os.path.isfile(FrameFile.path(p1, 29, 'jpg')))

            # thumbnails
            self.assertTrue(os.path.isfile(FrameFile.path(p1, 16, 'jpg', '192x192')))  # noqa
            self.assertTrue(os.path.isfile(FrameFile.path(p1, 17, 'jpg', '192x192')))  # noqa
            self.assertTrue(os.path.isfile(FrameFile.path(p1, 18, 'jpg', '192x192')))  # noqa
            self.assertTrue(os.path.isfile(FrameFile.path(p1, 19, 'jpg', '192x192')))  # noqa
            self.assertTrue(os.path.isfile(FrameFile.path(p1, 20, 'jpg', '192x192')))  # noqa
            self.assertTrue(os.path.isfile(FrameFile.path(p1, 21, 'jpg', '192x192')))  # noqa
            self.assertTrue(os.path.isfile(FrameFile.path(p1, 22, 'jpg', '192x192')))  # noqa
            self.assertTrue(os.path.isfile(FrameFile.path(p1, 23, 'jpg', '192x192')))  # noqa
            self.assertTrue(os.path.isfile(FrameFile.path(p1, 24, 'jpg', '192x192')))  # noqa
            self.assertTrue(os.path.isfile(FrameFile.path(p1, 25, 'jpg', '192x192')))  # noqa
            self.assertTrue(os.path.isfile(FrameFile.path(p1, 26, 'jpg', '192x192')))  # noqa
            self.assertTrue(os.path.isfile(FrameFile.path(p1, 27, 'jpg', '192x192')))  # noqa
            self.assertTrue(os.path.isfile(FrameFile.path(p1, 28, 'jpg', '192x192')))  # noqa
            self.assertTrue(os.path.isfile(FrameFile.path(p1, 29, 'jpg', '192x192')))  # noqa