def test_add_image_file(self, patch, image_files):
            imagefiles = ImageFileCollection(image_files)
            image_file_first = imagefiles.items[0]
            new_image_file = imagefiles.add(
                file_path="",
                timestamp=image_file_first.timestamp - timedelta(hours=1),
                timestamp_initial=image_file_first.timestamp_initial -
                timedelta(hours=1),
                cache_image=False)

            assert imagefiles.count == len(image_files) + 1
            assert new_image_file in imagefiles.items
            assert image_file_first != new_image_file
            assert imagefiles.items[0] == new_image_file
        def test_timestamps_initial(self, image_files):
            imagefiles = ImageFileCollection(image_files)

            assert len(imagefiles.timestamps_initial) == len(image_files)
            assert imagefiles.timestamps_initial == [
                image_file.timestamp_initial for image_file in image_files
            ]

            timestamp_initial = datetime(1, 1, 1, 1, 1, 1)
            imagefiles.timestamps_initial = timestamp_initial

            assert imagefiles.timestamps_initial == [
                image_file.timestamp_initial for image_file in image_files
            ]
        def test_file_paths(self, image_files):
            imagefiles = ImageFileCollection(image_files)

            assert len(imagefiles.file_paths) == len(image_files)
            assert imagefiles.file_paths == [
                image_file.file_path for image_file in image_files
            ]
        def test_timestamps(self, image_files):
            imagefiles = ImageFileCollection(image_files)

            assert len(imagefiles.timestamps) == len(image_files)
            assert imagefiles.timestamps == [
                image_file.timestamp for image_file in image_files
            ]
        def test_image_files_sorted(self, image_files):
            from random import sample

            image_files_shuffled = sample(image_files, len(image_files))
            imagefiles = ImageFileCollection(image_files_shuffled)

            assert imagefiles.items != image_files_shuffled
            assert imagefiles.items == image_files
        def test_from_path(self, mock_get_files_by_type, mock_file_exists,
                           timestamp_initial, tmp_path):
            results = ImageFileCollection.from_path(tmp_path, [])

            assert results.count == 1
            if timestamp_initial:
                assert results.timestamps_initial[
                    0] == ImageFile.timestamp_from_string(timestamp_initial)
            else:
                assert results.timestamps_initial[0] == results.items[
                    0].timestamp_initial
        def test_timestamps_elapsed(self, image_files):
            imagefiles = ImageFileCollection(image_files)

            assert len(imagefiles.timestamps_elapsed) == len(image_files)
            assert imagefiles.timestamps_elapsed == [
                image_file.timestamp_elapsed for image_file in image_files
            ]
            assert imagefiles.timestamps_elapsed_hours == [
                image_file.timestamp_elapsed_hours
                for image_file in image_files
            ]
            assert (imagefiles.timestamps_elapsed_minutes == [
                image_file.timestamp_elapsed_minutes
                for image_file in image_files
            ])
            assert (imagefiles.timestamps_elapsed_seconds == [
                image_file.timestamp_elapsed_seconds
                for image_file in image_files
            ])
        def test_image_file_count(self, image_files):
            imagefiles = ImageFileCollection(image_files)

            assert imagefiles.count == len(image_files)
        def test_init_list(self, image_files):
            imagefiles = ImageFileCollection(image_files)

            assert imagefiles.items == image_files
        def test_init(self):
            imagefiles = ImageFileCollection()

            assert imagefiles.items == list()
 def test_from_path_ioerror(self, mock_get_files_by_type,
                            mock_file_exists, tmp_path):
     with pytest.raises(IOError):
         ImageFileCollection.from_path(tmp_path, [])
 def test_from_path_filenotfound(self, tmp_path):
     with pytest.raises(FileNotFoundError):
         ImageFileCollection.from_path(tmp_path, [])