Ejemplo n.º 1
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")
Ejemplo n.º 2
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")
Ejemplo n.º 3
0
 def load_from(filename):
     try:
         mime = fs.guess_mime_type(filename)
         data = fs.read(filename)
         artwork_selection.artwork_loaded((mime, data))
     except Exception as e:
         artwork_selection.failed(e)
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
    def contains_track(self, album, filename, front_cover=None, **tags):
        if not exists(self.file(album, TRACKS_FOLDER_NAME, filename)):
            raise AssertionError("Track file '{}' not found in workspace".format(filename))

        track = tagging.load_track(self.file(album, TRACKS_FOLDER_NAME, filename))
        images = []
        # todo use builders and metadata
        if front_cover:
            image, desc = front_cover
            mime = fs.guess_mime_type(image)
            images.append(Image(mime, fs.read(image), type_=Image.FRONT_COVER, desc=desc))

        assert_that(track.metadata, has_entries(tags), "metadata tags")
        assert_that(track.metadata.images, contains(*images), "attached pictures")
Ejemplo n.º 6
0
def load_project(filename):
    album_folder = dirname(filename)
    tracks_folder = join(album_folder, TRACKS_FOLDER_NAME)
    artwork_folder = join(album_folder, ARTWORK_FOLDER_NAME)

    data = yaml.read_data(filename)
    if Version(data["version"]) < "1.10.0":
        data = _from_1_9_to_1_11(data)
    album = Album(Metadata(data), of_type=data["type"], filename=filename)

    for image in data["images"]:
        mime, filename, type_, desc = image
        album.add_image(mime, fs.read(join(artwork_folder, filename)), type_, desc)

    for track in data["tracks"]:
        album.add_track(_load_track(data["version"], tracks_folder, track))

    return album
Ejemplo n.º 7
0
def load_project(filename):
    album_folder = dirname(filename)
    tracks_folder = join(album_folder, TRACKS_FOLDER_NAME)
    artwork_folder = join(album_folder, ARTWORK_FOLDER_NAME)

    data = yaml.read_data(filename)
    if Version(data["version"]) < "1.10.0":
        data = _from_1_9_to_1_11(data)
    album = Album(Metadata(data), of_type=data["type"], filename=filename)

    for image in data["images"]:
        mime, filename, type_, desc = image
        album.add_image(mime, fs.read(join(artwork_folder, filename)), type_,
                        desc)

    for track in data["tracks"]:
        album.add_track(_load_track(data["version"], tracks_folder, track))

    return album
def _load_test_image(name):
    return fs.read(resources.path(name))
Ejemplo n.º 9
0
def image_file(path):
    return Image(mime=fs.guess_mime_type(path), data=fs.read(path), desc=os.path.basename(path))
Ejemplo n.º 10
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()
Ejemplo n.º 11
0
def image_file(path):
    return Image(mime=fs.guess_mime_type(path),
                 data=fs.read(path),
                 desc=os.path.basename(path))
def _load_test_image(name):
    return fs.read(resources.path(name))
Ejemplo n.º 13
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()