Esempio n. 1
0
def test_tagging_a_flac_track(app, recordings, workspace):
    app.new_project("St-Henri", of_type="flac")

    track = recordings.add_flac(release_name="ignore", lead_performer="ignore", track_title="???")
    app.add_tracks_to_project(track)

    app.shows_project_metadata(release_name="St-Henri", lead_performer="")
    app.change_project_metadata(release_name="St-Henri", front_cover=resources.path("st-henri.jpg"),
                                lead_performer="John Roney", isni="0000000121707484")

    app.shows_next_track_metadata(track_title="???")
    app.change_track_metadata(track_title="Squareboy", lyricist="Rebecca Ann Maloy", lyricist_ipi="9876543210000000")

    app.save_project()
    workspace.contains_track(album="St-Henri",
                             filename="John Roney - 01 - Squareboy.flac",
                             front_cover=(resources.path("st-henri.jpg"), "Front Cover"),
                             release_name="St-Henri",
                             lead_performer="John Roney",
                             lyricist=["Rebecca Ann Maloy"],
                             isnis={"John Roney": "0000000121707484"},
                             ipis={"Rebecca Ann Maloy": "9876543210000000"},
                             track_title="Squareboy",
                             track_number=1,
                             tagger_version=tgit.__version__)
Esempio n. 2
0
def test_tagging_a_flac_track(app, recordings, workspace):
    app.new_project("St-Henri", of_type="flac")

    track = recordings.add_flac(release_name="ignore",
                                lead_performer="ignore",
                                track_title="???")
    app.add_tracks_to_project(track)

    app.shows_project_metadata(release_name="St-Henri", lead_performer="")
    app.change_project_metadata(release_name="St-Henri",
                                front_cover=resources.path("st-henri.jpg"),
                                lead_performer="John Roney",
                                isni="0000000121707484")

    app.shows_next_track_metadata(track_title="???")
    app.change_track_metadata(track_title="Squareboy",
                              lyricist="Rebecca Ann Maloy",
                              lyricist_ipi="9876543210000000")

    app.save_project()
    workspace.contains_track(album="St-Henri",
                             filename="John Roney - 01 - Squareboy.flac",
                             front_cover=(resources.path("st-henri.jpg"),
                                          "Front Cover"),
                             release_name="St-Henri",
                             lead_performer="John Roney",
                             lyricist=["Rebecca Ann Maloy"],
                             isnis={"John Roney": "0000000121707484"},
                             ipis={"Rebecca Ann Maloy": "9876543210000000"},
                             track_title="Squareboy",
                             track_number=1,
                             tagger_version=tgit.__version__)
Esempio n. 3
0
def test_tagging_an_mp3_track(app, recordings, workspace):
    app.new_project("Honeycomb", of_type="mp3")

    track = recordings.add_mp3(release_name="ignore",
                               lead_performer="ignore",
                               track_title="???")
    app.add_tracks_to_project(track)

    app.shows_project_metadata(release_name="Honeycomb", lead_performer="")
    app.change_project_metadata(front_cover=resources.path("honeycomb.jpg"),
                                release_name="Honeycomb",
                                lead_performer="Joel Miller",
                                isni="0000000121707484")

    app.shows_next_track_metadata(track_title="???")
    app.change_track_metadata(track_title="Rashers",
                              lyricist="Rebecca Ann Maloy",
                              lyricist_ipi="9876543210000000")

    app.save_project()
    workspace.contains_track(album="Honeycomb",
                             filename="Joel Miller - 01 - Rashers.mp3",
                             front_cover=(resources.path("honeycomb.jpg"),
                                          "Front Cover"),
                             release_name="Honeycomb",
                             lead_performer="Joel Miller",
                             lyricist=["Rebecca Ann Maloy"],
                             isnis={"Joel Miller": "0000000121707484"},
                             ipis={"Rebecca Ann Maloy": "9876543210000000"},
                             track_title="Rashers",
                             track_number=1,
                             tagger_version=tgit.__version__)
Esempio n. 4
0
def test_tagging_an_mp3_track(app, recordings, workspace):
    app.new_project("Honeycomb", of_type="mp3")

    track = recordings.add_mp3(release_name="ignore", lead_performer="ignore", track_title="???")
    app.add_tracks_to_project(track)

    app.shows_project_metadata(release_name="Honeycomb", lead_performer="")
    app.change_project_metadata(front_cover=resources.path("honeycomb.jpg"),
                                release_name="Honeycomb", lead_performer="Joel Miller", isni="0000000121707484")

    app.shows_next_track_metadata(track_title="???")
    app.change_track_metadata(track_title="Rashers", lyricist="Rebecca Ann Maloy", lyricist_ipi="9876543210000000")

    app.save_project()
    workspace.contains_track(album="Honeycomb",
                             filename="Joel Miller - 01 - Rashers.mp3",
                             front_cover=(resources.path("honeycomb.jpg"), "Front Cover"),
                             release_name="Honeycomb",
                             lead_performer="Joel Miller",
                             lyricist=["Rebecca Ann Maloy"],
                             isnis={"Joel Miller": "0000000121707484"},
                             ipis={"Rebecca Ann Maloy": "9876543210000000"},
                             track_title="Rashers",
                             track_number=1,
                             tagger_version=tgit.__version__)
Esempio n. 5
0
def test_signals_when_project_selected(driver):
    project_selected_signal = ValueMatcherProbe("project file selected",
                                                resources.path("album.tgit"))
    _ = show_dialog(on_select=lambda dest: project_selected_signal.received(
        os.path.abspath(dest)))

    driver.load(resources.path("album.tgit"))
    driver.check(project_selected_signal)
Esempio n. 6
0
def test_changes_project_artwork_to_specified_image_file():
    project = make_album(images=[make_image(mime="image/gif", data="old cover")])

    image = "image/jpeg", fs.read(resources.path("front-cover.jpg"))
    make_cover_art_selection(project=project).artwork_loaded(image)

    assert_that(project.images, contains(has_properties(mime="image/jpeg",
                                                        data=fs.read(resources.path("front-cover.jpg")),
                                                        type=Image.FRONT_COVER,
                                                        desc="Front Cover")), "images")
def test_signals_selected_files(driver):
    mp3s = (resources.path("audio", "Rolling in the Deep.mp3"),
            resources.path("audio", "Set Fire to the Rain.mp3"),
            resources.path("audio", "Someone Like You.mp3"))

    tracks_selection_signal = ValueMatcherProbe("track(s) selection",
                                                contains(*mp3s))

    _ = show_dialog(on_select_files=lambda *sel: tracks_selection_signal.
                    received(_abs_path(sel)))

    driver.select_tracks(*mp3s)
    driver.check(tracks_selection_signal)
def test_alternatively_selects_files_of_given_type_in_folder(driver):
    mp3s = (resources.path("audio", "Rolling in the Deep.mp3"),
            resources.path("audio", "Set Fire to the Rain.mp3"),
            resources.path("audio", "Someone Like You.mp3"))

    tracks_selection_signal = ValueMatcherProbe("track(s) selection",
                                                contains_inanyorder(*mp3s))

    _ = show_dialog(on_select_files_in_folder=lambda *sel:
                    tracks_selection_signal.received(_abs_path(sel)))

    driver.select_tracks_in_folder(resources.path("audio"))
    driver.check(tracks_selection_signal)
Esempio n. 9
0
def test_changes_project_artwork_to_specified_image_file():
    project = make_album(
        images=[make_image(mime="image/gif", data="old cover")])

    image = "image/jpeg", fs.read(resources.path("front-cover.jpg"))
    make_cover_art_selection(project=project).artwork_loaded(image)

    assert_that(
        project.images,
        contains(
            has_properties(mime="image/jpeg",
                           data=fs.read(resources.path("front-cover.jpg")),
                           type=Image.FRONT_COVER,
                           desc="Front Cover")), "images")
Esempio n. 10
0
def test_reports_failure_on_file_not_found():
    cover_file = resources.path("missing_file.jpg")

    cover_art_selection = flexmock()
    cover_art_selection.should_receive("failed").with_args(match_equality(instance_of(FileNotFoundError))).once()

    artwork.load(cover_art_selection)(cover_file)
Esempio n. 11
0
def test_reports_image_on_successful_load():
    cover_file = resources.path("front-cover.jpg")
    cover_file_data = fs.read(cover_file)

    cover_art_selection = flexmock()
    cover_art_selection.should_receive("artwork_loaded").with_args(("image/jpeg", cover_file_data)).once()

    artwork.load(cover_art_selection)(cover_file)
def test_overwrites_previous_history_on_store(store):
    cover_art = image_file(resources.path("front-cover.jpg"))
    store.store_history(make_project_history(make_snapshot(name="Previous", path="previous.tgit", cover_art=cover_art)))
    store.store_history(make_project_history(make_snapshot(name="Last", path="last.tgit")))

    overwritten_history = store.load_history()

    assert_that(overwritten_history, contains(snapshot_with(name="Last", path="last.tgit", cover_art=None)),
                "overwritten history")
def test_signals_selected_file(driver):
    mp3 = resources.path("audio", "Rolling in the Deep.mp3")
    track_selection_signal = ValueMatcherProbe("track selection", mp3)

    _ = show_dialog(on_select_file=lambda sel: track_selection_signal.received(
        os.path.abspath(sel)))

    driver.select_tracks(mp3)
    driver.check(track_selection_signal)
def test_round_trips_history_including_cover_thumbnail_to_settings_file(store):
    cover_art = image_file(resources.path("front-cover.jpg"))
    store.store_history(make_project_history(make_snapshot(name="Last", path="last.tgit", cover_art=cover_art),
                                             make_snapshot(name="Previous", path="previous.tgit")))

    persisted_history = store.load_history()

    assert_that(persisted_history, contains(
        snapshot_with(name="Last", path="last.tgit", cover_art=image_with(mime=cover_art.mime, data=cover_art.data,
                                                                          desc=cover_art.desc, type=cover_art.type)),
        snapshot_with(name="Previous", path="previous.tgit")), "persisted history")
Esempio n. 15
0
def test_edit_excel_file(excel_file):
    wb = load_workbook(resources.path("soproq.xlsx"))
    ws = wb.active
    ws["A13"] = "Album title"

    save_to = excel_file("soproq.xlsx")
    wb.save(save_to)

    wb = load_workbook(save_to)
    ws = wb.active
    assert_that(ws["A13"].value, equal_to("Album title"), "the album title")
def test_restricts_selection_based_on_file_type(driver):
    flac_file = resources.path("audio", "Zumbar.flac")
    tracks_selection_signal = ValueMatcherProbe("track(s) selection",
                                                contains(flac_file))

    _ = show_dialog("flac",
                    on_select_files=lambda *sel: tracks_selection_signal.
                    received(_abs_path(sel)))

    driver.select_tracks(flac_file)
    driver.check(tracks_selection_signal)
Esempio n. 17
0
def test_scales_image_to_specified_size_preserving_image_attributes():
    original_image = image_file(resources.path("front-cover.jpg"))
    scaled_image = imager.scale(original_image, 50, 50)

    assert_that(scaled_image, image_with(data=not_(empty()),
                                         mime=original_image.mime,
                                         type=original_image.type,
                                         desc=original_image.desc), "scaled image")

    picture = QImage.fromData(scaled_image.data, imager.format_for(original_image.mime))
    assert_that(picture.width(), equal_to(50), "width")
    assert_that(picture.height(), equal_to(50), "height")
Esempio n. 18
0
def test_scales_image_to_specified_size_preserving_image_attributes():
    original_image = image_file(resources.path("front-cover.jpg"))
    scaled_image = imager.scale(original_image, 50, 50)

    assert_that(
        scaled_image,
        image_with(data=not_(empty()),
                   mime=original_image.mime,
                   type=original_image.type,
                   desc=original_image.desc), "scaled image")

    picture = QImage.fromData(scaled_image.data,
                              imager.format_for(original_image.mime))
    assert_that(picture.width(), equal_to(50), "width")
    assert_that(picture.height(), equal_to(50), "height")
Esempio n. 19
0
def test_overwrites_previous_history_on_store(store):
    cover_art = image_file(resources.path("front-cover.jpg"))
    store.store_history(
        make_project_history(
            make_snapshot(name="Previous",
                          path="previous.tgit",
                          cover_art=cover_art)))
    store.store_history(
        make_project_history(make_snapshot(name="Last", path="last.tgit")))

    overwritten_history = store.load_history()

    assert_that(
        overwritten_history,
        contains(snapshot_with(name="Last", path="last.tgit", cover_art=None)),
        "overwritten history")
Esempio n. 20
0
def test_round_trips_history_including_cover_thumbnail_to_settings_file(store):
    cover_art = image_file(resources.path("front-cover.jpg"))
    store.store_history(
        make_project_history(
            make_snapshot(name="Last", path="last.tgit", cover_art=cover_art),
            make_snapshot(name="Previous", path="previous.tgit")))

    persisted_history = store.load_history()

    assert_that(
        persisted_history,
        contains(
            snapshot_with(name="Last",
                          path="last.tgit",
                          cover_art=image_with(mime=cover_art.mime,
                                               data=cover_art.data,
                                               desc=cover_art.desc,
                                               type=cover_art.type)),
            snapshot_with(name="Previous", path="previous.tgit")),
        "persisted history")
Esempio n. 21
0
def test_reads_data_from_yaml_file():
    data = yaml.read_data(resources.path("album.tgit"))

    assert_that(data, has_entry("version", "1.11.0"), "version")
    assert_that(data, has_entry("type", "mp3"), "album type")
    assert_that(data, has_entry("release_name", "Title"), "release name")
    assert_that(data, has_entry("compilation", True), "compilation")
    assert_that(data, has_entry("lead_performer", equal_to("Artist")), "lead performer")
    assert_that(data, has_entry("lead_performer_region", ("FR",)), "lead performer region")
    assert_that(data, has_entry("isnis", has_entry("Artist", "0000000123456789")), "isnis")
    assert_that(data, has_entry("guest_performers", contains(("Guitar", "Guitarist"), ("Piano", "Pianist"))),
                "guest performers")
    assert_that(data, has_entry("label_name", "Label"), "label name")
    assert_that(data, has_entry("catalog_number", "XXX123456789"), "catalog number")
    assert_that(data, has_entry("upc", "123456789999"), "upc")
    assert_that(data, has_entry("comments", "Comments\n..."), "comments")
    assert_that(data, has_entry("release_time", "2009-01-01"), "release time")
    assert_that(data, has_entry("recording_time", "2008-09-15"), "recording time")
    assert_that(data, has_entry("original_release_time", "2009-01-15"), "original_release time")
    assert_that(data, has_entry("contributors", contains(("Sound", "Sound Engineer"), ("Effects", "Effects Engineer"))),
                "contributors")
    assert_that(data, has_entry("images", contains(("image/jpeg", "Front.jpeg", Image.FRONT_COVER, "Front"))),
                "attached pictures")
    assert_that(data, has_entry("tracks", contains("1st", "2nd", "3rd")))
Esempio n. 22
0
def test_migrates_to_v1_11():
    stored_album = local_project.load_project(resources.path("album-v1.9.tgit"))

    assert_that(stored_album.isnis, has_entry("Artist", "0000000123456789"), "lead performer identity")
Esempio n. 23
0
import pytest
from hamcrest import assert_that, contains, has_property, equal_to, empty, is_, has_entry, has_entries

from testing import builders as build, mp3_file
from testing import resources
from testing.builders import make_track, make_chain_of_title
from tgit import fs
from tgit.album import Album
from tgit.local_storage import local_project
from tgit.local_storage.local_project import TRACKS_FOLDER_NAME, ARTWORK_FOLDER_NAME
from tgit.metadata import Image

pytestmark = pytest.mark.unit

sample_front_cover = "image/jpeg", fs.read(
    resources.path("front-cover.jpg")), Image.FRONT_COVER, "Front Cover"


def simple_naming(track):
    return track.track_title + ".mp3"


@pytest.yield_fixture
def project_file(tmpdir):
    folder = tmpdir.join("album")

    def filename(*paths):
        return folder.join(*paths).strpath

    yield filename
    folder.remove()
def test_only_accepts_tgit_project_files(driver):
    _ = show_dialog()

    driver.rejects_selection_of(resources.path("base.mp3"))
Esempio n. 25
0
def test_migrates_to_v1_11():
    stored_album = local_project.load_project(
        resources.path("album-v1.9.tgit"))

    assert_that(stored_album.isnis, has_entry("Artist", "0000000123456789"),
                "lead performer identity")
Esempio n. 26
0
def test_ignores_copy_to_same_destination(tmpdir):
    track_file = tmpdir.join("track.mp3").strpath
    fs.copy(resources.path("base.mp3"), track_file)

    fs.copy(track_file, track_file)
def _load_test_image(name):
    return fs.read(resources.path(name))
Esempio n. 28
0
def test_only_accepts_tgit_project_files(driver):
    _ = show_dialog()

    driver.rejects_selection_of(resources.path("base.mp3"))
Esempio n. 29
0
def test_creates_temp_file_from_filename(media_library):
    media_library.fetch(resources.path("audio", "Rolling in the Deep.mp3"))
    assert_that(os.listdir(media_library._directory), is_not(empty()),
                "the media library's content")
Esempio n. 30
0
def test_creates_qmediacontent_for_temp_file(media_library):
    media_content = media_library.fetch(
        resources.path("audio", "Rolling in the Deep.mp3"))
    assert_that(os.path.normpath(media_content.canonicalUrl().toLocalFile()),
                starts_with(media_library._directory),
                "the media content's source file")
Esempio n. 31
0
def make(from_=test_resources.path("base.mp3"), to=None, **tags):
    audio = Mp3Audio(fs.make_temp_copy(from_, to))
    audio.tag(**tags)
    return audio
def test_signals_when_project_selected(driver):
    project_selected_signal = ValueMatcherProbe("project file selected", resources.path("album.tgit"))
    _ = show_dialog(on_select=lambda dest: project_selected_signal.received(os.path.abspath(dest)))

    driver.load(resources.path("album.tgit"))
    driver.check(project_selected_signal)
Esempio n. 33
0
import pytest
from hamcrest import assert_that, contains, has_property, equal_to, empty, is_, has_entry, has_entries

from testing import builders as build, mp3_file
from testing import resources
from testing.builders import make_track, make_chain_of_title
from tgit import fs
from tgit.album import Album
from tgit.local_storage import local_project
from tgit.local_storage.local_project import TRACKS_FOLDER_NAME, ARTWORK_FOLDER_NAME
from tgit.metadata import Image

pytestmark = pytest.mark.unit

sample_front_cover = "image/jpeg", fs.read(resources.path("front-cover.jpg")), Image.FRONT_COVER, "Front Cover"


def simple_naming(track):
    return track.track_title + ".mp3"


@pytest.yield_fixture
def project_file(tmpdir):
    folder = tmpdir.join("album")

    def filename(*paths):
        return folder.join(*paths).strpath

    yield filename
    folder.remove()
Esempio n. 34
0
class Base(object):
    filename = resources.path("base.flac")
    bitrate = 705600
    duration = 5.0
Esempio n. 35
0
def test_signals_when_artwork_selected(driver, artwork_selection):
    signal = ValueMatcherProbe("file selected", resources.path("front-cover.jpg"))
    _ = show_dialog(artwork_selection, lambda destination: signal.received(os.path.abspath(destination)))

    driver.select(resources.path("front-cover.jpg"))
    driver.check(signal)
Esempio n. 36
0
def test_only_accepts_files_from_mime_type_filters(driver):
    _ = show_dialog("text/csv")
    driver.rejects_selection_of(resources.path("base.mp3"))
Esempio n. 37
0
def test_ignores_copy_to_same_destination(tmpdir):
    track_file = tmpdir.join("track.mp3").strpath
    fs.copy(resources.path("base.mp3"), track_file)

    fs.copy(track_file, track_file)
Esempio n. 38
0
def test_creates_temp_directory(media_library):
    media_library.fetch(resources.path("audio", "Rolling in the Deep.mp3"))
    assert_that(os.path.exists(media_library._directory), is_(True),
                "the media library's temporary directory exists")
def _load_test_image(name):
    return fs.read(resources.path(name))
Esempio n. 40
0
def test_removes_all_temp_files_on_close(media_library):
    media_library.fetch(resources.path("audio", "Rolling in the Deep.mp3"))
    media_library.dispose()
    assert_that(os.path.exists(media_library._directory), is_(False),
                "the media library's temporary directory exists")
Esempio n. 41
0
def make(from_=test_resources.path("base.mp3"), to=None, **tags):
    audio = Mp3Audio(fs.make_temp_copy(from_, to))
    audio.tag(**tags)
    return audio
Esempio n. 42
0
def test_only_accepts_files_from_mime_type_filters(driver):
    _ = show_dialog("text/csv")
    driver.rejects_selection_of(resources.path("base.mp3"))
def test_only_accept_audio_files(driver):
    unsupported_file = resources.path("front-cover.jpg")

    _ = show_dialog(on_select_file=lambda: None)

    driver.rejects_selection_of(unsupported_file)