def test_imports_project_from_an_existing_track_if_specified( studio, album_catalog, track_catalog): reference_track = make_track(filename="track.mp3", release_name="Track Release", lead_performer="Track Artist", track_title="Track Title") track_catalog.should_receive("load_track").with_args( "track.mp3").and_return(reference_track) imported_project = matching( project_with(release_name="Project", lead_performer="Track Artist", tracks=contains(track_with(track_title="Track Title")))) album_catalog.should_receive("save_project").with_args( imported_project).once().ordered() studio.should_receive("project_created").with_args( imported_project).once().ordered() project.create_in(studio, to_catalog=album_catalog, from_catalog=track_catalog)( type_="mp3", name="Project", location="/workspace", reference_track_file="track.mp3")
def test_signals_when_user_signs_out(listener): session = make_registered_session("*****@*****.**", "api-key") listener.should_receive("user_signed_out").with_args( matching(has_property("email", equal_to("*****@*****.**")))).once() session.user_signed_out.subscribe(listener.user_signed_out) session.logout()
def test_signals_when_user_signs_in(listener): session = make_anonymous_session() listener.should_receive("user_signed_in").with_args( matching(has_property("email", equal_to("*****@*****.**")))).once() session.user_signed_in.subscribe(listener.user_signed_in) session.login_as("*****@*****.**", "api-key", ())
def test_saves_history_to_store_whenever_it_changes(studio, store): history = make_project_history() store.should_receive("load_history").and_return(history) store.should_receive("store_history").with_args(matching(contains(snapshot_with(path="/new")))).once() history = load_from(studio, store) history.project_opened(make_project("/new"))
def test_creates_and_adds_new_project_to_catalog_and_then_reports_creation_to_studio(studio, album_catalog): new_project = matching( project_with(type="mp3", filename=os.path.normpath("/workspace/Project/Project.tgit"), release_name="Project")) album_catalog.should_receive("save_project").with_args(new_project).once().ordered() studio.should_receive("project_created").with_args(new_project).once().ordered() project.create_in(studio, to_catalog=album_catalog)(type_="mp3", name="Project", location=os.path.normpath("/workspace"))
def test_saves_history_to_store_whenever_it_changes(studio, store): history = make_project_history() store.should_receive("load_history").and_return(history) store.should_receive("store_history").with_args( matching(contains(snapshot_with(path="/new")))).once() history = load_from(studio, store) history.project_opened(make_project("/new"))
def tests_stores_user_preferences_on_change(store): prefs = make_preferences(locale="fr") store.should_receive("load_preferences").and_return(prefs) preferences = load_from(store) store.should_receive("store_preferences").with_args( matching(has_properties(locale="en"))).once() preferences.locale = "en"
def tests_stores_user_credentials_in_settings_store_on_sign_in(store): store.should_receive("load_user").and_return(User.anonymous()) session = load_session_from(store) store.should_receive("store_user").with_args( matching(has_properties(email="*****@*****.**", api_key="token", permissions=contains("isni.lookup", "isni.assign")))).once() session.login_as("*****@*****.**", "token", ("isni.lookup", "isni.assign"))
def test_snapshots_thumbnail_of_project_main_cover(scaler): project = make_project(images=[make_image(mime="image/png", data=b'<image data>')]) scaler.should_receive("scale").with_args( matching(image_with(mime="image/png", data=b'<image data>')), 64, 64).and_return( Image(mime="image/png", data=b'<scaled image data>')) snapshot = ProjectSnapshot.of(project, image_editor=scaler) project.remove_images() assert_that(snapshot.cover_art, image_with(mime="image/png", data=b'<scaled image data>'), "snapshot's thumbnail")
def test_imports_project_from_an_existing_track_if_specified(studio, album_catalog, track_catalog): reference_track = make_track(filename="track.mp3", release_name="Track Release", lead_performer="Track Artist", track_title="Track Title") track_catalog.should_receive("load_track").with_args("track.mp3").and_return(reference_track) imported_project = matching(project_with(release_name="Project", lead_performer="Track Artist", tracks=contains(track_with(track_title="Track Title")))) album_catalog.should_receive("save_project").with_args(imported_project).once().ordered() studio.should_receive("project_created").with_args(imported_project).once().ordered() project.create_in(studio, to_catalog=album_catalog, from_catalog=track_catalog)( type_="mp3", name="Project", location="/workspace", reference_track_file="track.mp3")
def test_snapshots_thumbnail_of_project_main_cover(scaler): project = make_project( images=[make_image(mime="image/png", data=b'<image data>')]) scaler.should_receive("scale").with_args( matching(image_with(mime="image/png", data=b'<image data>')), 64, 64).and_return(Image(mime="image/png", data=b'<scaled image data>')) snapshot = ProjectSnapshot.of(project, image_editor=scaler) project.remove_images() assert_that(snapshot.cover_art, image_with(mime="image/png", data=b'<scaled image data>'), "snapshot's thumbnail")
def test_creates_and_adds_new_project_to_catalog_and_then_reports_creation_to_studio( studio, album_catalog): new_project = matching( project_with( type="mp3", filename=os.path.normpath("/workspace/Project/Project.tgit"), release_name="Project")) album_catalog.should_receive("save_project").with_args( new_project).once().ordered() studio.should_receive("project_created").with_args( new_project).once().ordered() project.create_in(studio, to_catalog=album_catalog)( type_="mp3", name="Project", location=os.path.normpath("/workspace"))
def exception_with_message(message): return matching(has_args_containing(message))