Beispiel #1
0
def test_add_vtt_files_to_movie_content_skips_existing(
        tmp_path: PosixPath) -> None:
    videos: List[str] = ["eng.vtt", "subtitle.vtt"]
    existing: PosixPath = tmp_path / videos[0]
    for video in videos:
        (tmp_path / video).touch()
    movie_subtitle: MovieSubtitle = MovieSubtitleFactory(
        full_path=str(existing),
        relative_path=existing.relative_to(existing.parent.parent.parent),
        file_name=existing.name,
        suffix=existing.suffix,
    )
    movie_content: MovieContent = MovieContentFactory.create(
        movie_subtitle=[movie_subtitle])

    assert MovieSubtitle.objects.count() == 1
    assert movie_content.movie_subtitle.count() == 1

    _add_vtt_files_to_movie_content(movie_content=movie_content,
                                    subtitles_folder=tmp_path)
    movie_content.refresh_from_db()

    assert MovieSubtitle.objects.count() == 2
    assert movie_content.movie_subtitle.count() == 2

    movie_subtitles = movie_content.movie_subtitle.all()

    for index, movie_subtitle in enumerate(movie_subtitles):
        assert movie_subtitle.full_path == str(tmp_path / videos[index])
        assert movie_subtitle.relative_path == str(
            Path(tmp_path.parent.name) / tmp_path.name / videos[index])
        assert movie_subtitle.file_name == videos[index]
        assert movie_subtitle.suffix == ".vtt"
Beispiel #2
0
def movie_content() -> MovieContent:
    return MovieContentFactory.create(is_ready=True, full_path="/path")