def test_displays_all_tracks_in_rows(driver): _ = show_track_list_tab(make_album(tracks=[make_track(track_title="Chevere!"), make_track(track_title="Honeycomb")])) driver.has_track_count(2) driver.shows_tracks_in_order(["1", "Chevere!"], ["2", "Honeycomb"])
def test_closes_children_pages_on_close(driver): closed_signals = MultiValueMatcherProbe( "closed pages", contains("track_edition_page_3", "track_edition_page_2", "track_edition_page_1", "project_edition_page")) def record_close(create_page): @wraps(create_page) def wrapper(*args, **kwargs): page = create_page(*args, **kwargs) page.closed.connect( lambda: closed_signals.received(page.objectName())) return page return wrapper _ = show_project_screen( make_album(tracks=(make_track(), make_track(), make_track())), record_close(create_project_page), record_close(create_track_page)) driver.close() driver.has_no_project_edition_page() driver.has_no_track_edition_page() driver.check(closed_signals)
def test_updates_track_list_when_album_metadata_change(driver): album = make_album(tracks=[make_track(track_title="Chevere!"), make_track(track_title="Zumbar")]) _ = show_track_list_tab(album) album.release_name = "Honeycomb" driver.shows_tracks_in_order(["Chevere!", "Honeycomb"], ["Zumbar", "Honeycomb"])
def test_closes_children_pages_on_close(driver): closed_signals = MultiValueMatcherProbe("closed pages", contains( "track_edition_page_3", "track_edition_page_2", "track_edition_page_1", "project_edition_page")) def record_close(create_page): @wraps(create_page) def wrapper(*args, **kwargs): page = create_page(*args, **kwargs) page.closed.connect(lambda: closed_signals.received(page.objectName())) return page return wrapper _ = show_project_screen(make_album(tracks=(make_track(), make_track(), make_track())), record_close(create_project_page), record_close(create_track_page)) driver.close() driver.has_no_project_edition_page() driver.has_no_track_edition_page() driver.check(closed_signals)
def test_reorders_navigation_menu_when_moving_a_track(driver): album = make_album(tracks=[make_track(track_title="Chevere!"), make_track(track_title="That is that")]) _ = show_project_screen(album) driver.shows_pages_in_navigation_combo("Project edition", "1 - Chevere!", "2 - That is that") album.move_track(from_position=0, to_position=1) driver.shows_pages_in_navigation_combo("Project edition", "1 - That is that", "2 - Chevere!")
def test_removes_track_menu_item_when_removing_a_track_from_the_project(driver): album = make_album(tracks=[(make_track(track_title="Chevere!")), (make_track(track_title="That is that"))]) _ = show_project_screen(album) driver.shows_pages_in_navigation_combo("Project edition", "1 - Chevere!", "2 - That is that") album.remove_track(0) driver.shows_pages_in_navigation_combo("Project edition", "1 - That is that")
def test_shows_selected_track_title_in_context_menu(driver): _ = show_track_list_tab(make_album(tracks=[make_track(track_title="Partways"), make_track(track_title="Rebop")])) driver.select_track("Partways") driver.has_context_menu_item(with_text(contains_string("Partways"))) driver.select_track("Rebop") driver.has_context_menu_item(with_text(contains_string("Rebop")))
def test_displays_works(driver): selection = IdentitySelection( make_album(tracks=[ make_track(track_title="Chevere!"), make_track(track_title="Zumbar") ]), "") _ = show_dialog(selection) driver.has_works("Chevere!", "Zumbar")
def test_makes_remove_track_request_with_selected_track_when_track_removed(driver, using): page = show_track_list_tab(make_album(tracks=[make_track(), make_track(track_title="Chevere!")])) remove_request = ValueMatcherProbe("remove track request", 1) page.on_remove_track(remove_request.received) driver.select_track("Chevere!") driver.remove_selected_track(using=using) driver.check(remove_request)
def test_navigates_using_shortcut(driver): album = make_album(tracks=[ make_track(track_title="Chevere!"), make_track(track_title="That is that") ]) _ = show_project_screen(album) driver.quick_navigate_to_page("2") driver.shows_track_edition_page(2)
def test_adds_row_to_table_when_track_added_to_album(driver): album = make_album() _ = show_track_list_tab(album) album.add_track(make_track(track_title="Chevere!")) album.add_track(make_track(track_title="Zumbar!")) driver.has_track_count(2) driver.shows_tracks_in_order(["1", "Chevere!"], ["2", "Zumbar!"])
def test_displays_all_tracks_in_rows(driver): _ = show_track_list_tab( make_album(tracks=[ make_track(track_title="Chevere!"), make_track(track_title="Honeycomb") ])) driver.has_track_count(2) driver.shows_tracks_in_order(["1", "Chevere!"], ["2", "Honeycomb"])
def test_makes_move_track_request_when_track_row_moved(driver): page = show_track_list_tab(make_album(tracks=[make_track(track_title="Chaconne"), make_track(track_title="Choices"), make_track(track_title="Place St-Henri")])) track_moved_signal = MultiValueMatcherProbe("track moved", contains(2, 1)) page.on_move_track(track_moved_signal.received) driver.move_track("Place St-Henri", 1) driver.check(track_moved_signal)
def test_makes_move_track_request_when_track_moved_down(driver): page = show_track_list_tab( make_album(tracks=[make_track(track_title="Chaconne"), make_track(track_title="Choices")])) track_moved_signal = MultiValueMatcherProbe("track moved", contains(0, 1)) page.on_move_track(track_moved_signal.received) driver.select_track("Chaconne") driver.move_track_down() driver.check(track_moved_signal)
def test_removes_track_page_when_track_removed(driver): album = make_album(tracks=( make_track(track_title="track 1"), make_track(track_title="track 2"), make_track(track_title="track 3"))) _ = show_project_screen(album) driver.to_page("1 - track 1") driver.shows_track_edition_page(number=1) album.remove_track(position=1) driver.to_next_page() driver.shows_track_edition_page(number=3)
def test_displays_pages_in_navigation_combo(driver): tracks = [ make_track(track_title="track 1"), make_track(track_title="track 2"), make_track(track_title="track 3") ] _ = show_project_screen(make_album(tracks=tracks)) driver.shows_pages_in_navigation_combo("Project edition", "1 - track 1", "2 - track 2", "3 - track 3")
def test_disables_move_down_button_when_on_last_track_or_no_track_selected(driver): _ = show_track_list_tab(make_album(tracks=[make_track(track_title="Chaconne"), make_track(track_title="Choices")])) driver.move_down_button.is_disabled() driver.select_track("Chaconne") driver.move_down_button.is_enabled() driver.select_track("Choices") driver.move_down_button.is_disabled()
def test_shows_selected_track_title_in_context_menu(driver): _ = show_track_list_tab( make_album(tracks=[ make_track(track_title="Partways"), make_track(track_title="Rebop") ])) driver.select_track("Partways") driver.has_context_menu_item(with_text(contains_string("Partways"))) driver.select_track("Rebop") driver.has_context_menu_item(with_text(contains_string("Rebop")))
def test_removes_track_menu_item_when_removing_a_track_from_the_project( driver): album = make_album(tracks=[(make_track( track_title="Chevere!")), (make_track(track_title="That is that"))]) _ = show_project_screen(album) driver.shows_pages_in_navigation_combo("Project edition", "1 - Chevere!", "2 - That is that") album.remove_track(0) driver.shows_pages_in_navigation_combo("Project edition", "1 - That is that")
def test_updates_track_list_when_album_metadata_change(driver): album = make_album(tracks=[ make_track(track_title="Chevere!"), make_track(track_title="Zumbar") ]) _ = show_track_list_tab(album) album.release_name = "Honeycomb" driver.shows_tracks_in_order(["Chevere!", "Honeycomb"], ["Zumbar", "Honeycomb"])
def test_removes_track_page_when_track_removed(driver): album = make_album(tracks=(make_track(track_title="track 1"), make_track(track_title="track 2"), make_track(track_title="track 3"))) _ = show_project_screen(album) driver.to_page("1 - track 1") driver.shows_track_edition_page(number=1) album.remove_track(position=1) driver.to_next_page() driver.shows_track_edition_page(number=3)
def test_signals_track_move_events(): album = make_album(tracks=(make_track(track_title="Salsa Coltrane"), make_track(track_title="Zumbar"), make_track(track_title="Chevere!"))) subscriber = Subscriber() album.track_moved.subscribe(subscriber) album.move_track(1, 0) assert_that(subscriber.events, has_item(contains(has_title("Zumbar"), 1, 0)), "move event")
def test_reorders_navigation_menu_when_moving_a_track(driver): album = make_album(tracks=[ make_track(track_title="Chevere!"), make_track(track_title="That is that") ]) _ = show_project_screen(album) driver.shows_pages_in_navigation_combo("Project edition", "1 - Chevere!", "2 - That is that") album.move_track(from_position=0, to_position=1) driver.shows_pages_in_navigation_combo("Project edition", "1 - That is that", "2 - Chevere!")
def test_makes_remove_track_request_with_selected_track_when_track_removed( driver, using): page = show_track_list_tab( make_album(tracks=[make_track(), make_track(track_title="Chevere!")])) remove_request = ValueMatcherProbe("remove track request", 1) page.on_remove_track(remove_request.received) driver.select_track("Chevere!") driver.remove_selected_track(using=using) driver.check(remove_request)
def test_moves_and_select_row_in_table_accordingly_when_track_position_changes(driver): tracks = (make_track(track_title="Chevere!"), make_track(track_title="Zumbar"), make_track(track_title="Salsa Coltrane")) album = make_album(tracks=tracks) _ = show_track_list_tab(album) driver.shows_tracks_in_order(["Chevere!"], ["Zumbar"], ["Salsa Coltrane"]) driver.select_track("Salsa Coltrane") album.move_track(2, 1) driver.shows_tracks_in_order(["Chevere!"], ["Salsa Coltrane"], ["Zumbar"]) driver.has_selected_track("Salsa Coltrane")
def test_makes_move_track_request_when_track_moved_down(driver): page = show_track_list_tab( make_album(tracks=[ make_track(track_title="Chaconne"), make_track(track_title="Choices") ])) track_moved_signal = MultiValueMatcherProbe("track moved", contains(0, 1)) page.on_move_track(track_moved_signal.received) driver.select_track("Chaconne") driver.move_track_down() driver.check(track_moved_signal)
def test_moves_and_select_row_in_table_accordingly_when_track_position_changes( driver): tracks = (make_track(track_title="Chevere!"), make_track(track_title="Zumbar"), make_track(track_title="Salsa Coltrane")) album = make_album(tracks=tracks) _ = show_track_list_tab(album) driver.shows_tracks_in_order(["Chevere!"], ["Zumbar"], ["Salsa Coltrane"]) driver.select_track("Salsa Coltrane") album.move_track(2, 1) driver.shows_tracks_in_order(["Chevere!"], ["Salsa Coltrane"], ["Zumbar"]) driver.has_selected_track("Salsa Coltrane")
def test_removes_row_from_table_when_track_removed_from_album(driver): album = make_album(tracks=(make_track(track_title="Chevere!"), make_track(track_title="Zumbar"), make_track(track_title="Salsa Coltrane"))) _ = show_track_list_tab(album) driver.shows_tracks_in_order(["Chevere!"], ["Zumbar"], ["Salsa Coltrane"]) album.remove_track(1) driver.shows_tracks_in_order(["Chevere!"], ["Salsa Coltrane"]) album.remove_track(1) driver.shows_tracks_in_order(["Chevere!"]) album.remove_track(0) driver.shows_tracks_in_order()
def test_makes_move_track_request_when_track_row_moved(driver): page = show_track_list_tab( make_album(tracks=[ make_track(track_title="Chaconne"), make_track(track_title="Choices"), make_track(track_title="Place St-Henri") ])) track_moved_signal = MultiValueMatcherProbe("track moved", contains(2, 1)) page.on_move_track(track_moved_signal.received) driver.move_track("Place St-Henri", 1) driver.check(track_moved_signal)
def test_navigates_using_the_combo_box(driver): tracks = [make_track(track_title="track 1"), make_track(track_title="track 2"), make_track(track_title="track 3")] _ = show_project_screen(make_album(tracks=tracks)) driver.to_page("3 - track 3") driver.shows_track_edition_page(3) driver.to_page("2 - track 2") driver.shows_track_edition_page(2) driver.to_page("1 - track 1") driver.shows_track_edition_page(1) driver.to_page("Project edition") driver.shows_project_edition_page()
def test_disables_move_down_button_when_on_last_track_or_no_track_selected( driver): _ = show_track_list_tab( make_album(tracks=[ make_track(track_title="Chaconne"), make_track(track_title="Choices") ])) driver.move_down_button.is_disabled() driver.select_track("Chaconne") driver.move_down_button.is_enabled() driver.select_track("Choices") driver.move_down_button.is_disabled()
def test_offers_goto_page_navigation(driver): _ = show_project_screen(make_album(tracks=( make_track(track_title="track 1"), make_track(track_title="track 2"), make_track(track_title="track 3")))) driver.to_page("Project edition") driver.shows_project_edition_page() driver.to_page("1 - track 1") driver.shows_track_edition_page(1) driver.to_page("2 - track 2") driver.shows_track_edition_page(2) driver.to_page("3 - track 3") driver.shows_track_edition_page(3)
def test_updates_the_displayed_page_when_updating_track_title(driver): track = make_track(track_title="track 1") _ = show_project_screen(make_album(tracks=[track])) driver.shows_pages_in_navigation_combo("Project edition", "1 - track 1") track.track_title = "Chevere!" driver.shows_pages_in_navigation_combo("Project edition", "1 - Chevere!")
def test_disables_lead_performer_edition_when_album_is_not_a_compilation(driver): track = make_track() album = make_album(lead_performer="Album Artist", compilation=False, tracks=[track]) _ = show_page(album, track) driver.shows_lead_performer("Album Artist", disabled=True)
def test_indicates_when_album_performed_by_various_artists(driver): track = make_track() album = make_album(compilation=True, tracks=[track]) _ = show_page(album, track) driver.shows_album_lead_performer("Various Artists")
def test_moves_track_page_when_track_moved(driver): album = make_album(tracks=( make_track(track_title="track 1"), make_track(track_title="track 2"), make_track(track_title="track 3"))) _ = show_project_screen(album) driver.to_page("1 - track 1") driver.shows_track_edition_page(1) album.move_track(from_position=0, to_position=2) driver.shows_track_edition_page(2) driver.to_next_page() driver.shows_track_edition_page(3) driver.to_next_page() driver.shows_track_edition_page(1)
def test_omits_software_notice_if_tagging_date_malformed(driver): track = make_track(tagger="TGiT", tagger_version="1.0", tagging_time="invalid-time-format") album = make_album(tracks=[track]) _ = show_page(album, track) driver.shows_software_notice("Tagged with TGiT v1.0")
def test_unsubscribes_from_event_signals_on_close(driver): track = make_track() page = show_track_list_tab(make_album(tracks=[track])) page.close() assert_that(track.metadata_changed.subscribers, empty(), "'track metadata changed' subscriptions")
def test_updates_track_metadata(): track = make_track() track.update(track_title="Title", lead_performer="Artist", version_info="Version", featured_guest="Featuring", lyricist=["Lyricist"], composer=["Composer"], publisher=["Publisher"], isrc="ZZZ123456789", labels="Tags", lyrics="Lyrics\nLyrics\n...", language="und") assert_that(track.track_title, equal_to("Title"), "track title") assert_that(track.lead_performer, equal_to("Artist"), "lead performer") assert_that(track.version_info, equal_to("Version"), "version info") assert_that(track.featured_guest, equal_to("Featuring"), "featured guest") assert_that(track.lyricist, contains("Lyricist"), "lyricist") assert_that(track.composer, contains("Composer"), "composer") assert_that(track.publisher, contains("Publisher"), "publisher") assert_that(track.isrc, equal_to("ZZZ123456789"), "isrc") assert_that(track.labels, equal_to("Tags"), "tags") assert_that(track.lyrics, equal_to("Lyrics\nLyrics\n..."), "lyrics") assert_that(track.language, equal_to("und"), "language")
def test_displays_undefined_lyrics_language_in_case_no_language_specified(driver): track = make_track() album = make_album(tracks=[track]) _ = show_page(album, track) driver.shows_language("Undetermined")
def test_round_trips_chain_of_title_to_disk(project_file, mp3): album_file = project_file("album.tgit") original_filename = mp3() chain_of_title = make_chain_of_title( authors_composers=[joel_miller(), john_roney()], publishers=[effendi_records()]) original_track = make_track(original_filename, chain_of_title=chain_of_title, track_title="Chevere!") original_album = build.album(filename=album_file, version="2.4.0", type=Album.Type.FLAC, lead_performer="Joel Miller", tracks=[original_track]) local_project.save_project( original_album, track_name=lambda current_track: current_track.track_title + ".mp3") os.remove(original_filename) track = local_project.load_project(album_file).tracks[0] assert_that(track.chain_of_title.contributors, has_author_composer("Joel Miller", joel_miller()), "The contributors") assert_that(track.chain_of_title.contributors, has_author_composer("John Roney", john_roney()), "The contributors") assert_that(track.chain_of_title.contributors, has_publisher("Effendi Records", effendi_records()), "The contributors")
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_updates_collaborators_identifiers(driver): def isni_lookup(text): return isnis.get(text) def ipi_lookup(text): return ipis.get(text) isnis = {"Joel Miller": "000000123456789", "John Roney": "9876543210000000", "Rebecca Maloy": "0102030405060789"} ipis = {"Joel Miller": "0102030405060789", "John Roney": "000000123456789", "Rebecca Maloy": "9876543210000000"} track = make_track(lyricist=["Joel Miller"], composer=["John Roney"], publisher=["Rebecca Maloy"]) project = make_album(isnis=isnis, ipis=ipis, tracks=[track]) _ = show_page(track, on_isni_local_lookup=isni_lookup, on_ipi_local_lookup=ipi_lookup) isnis["Joel Miller"] = "0000001234567891" isnis["John Roney"] = "98765432100000001" isnis["Rebecca Maloy"] = "01020304050607891" ipis["Joel Miller"] = "01020304050607891" ipis["John Roney"] = "0000001234567891" ipis["Rebecca Maloy"] = "98765432100000001" project.metadata_changed.emit(project) driver.shows_row_details("Joel Miller", "01020304050607891", "0000001234567891") driver.shows_role_on_row(0, "Author") driver.shows_row_details("John Roney", "0000001234567891", "98765432100000001") driver.shows_role_on_row(1, "Composer") driver.shows_row_details("Rebecca Maloy", "98765432100000001", "01020304050607891") driver.shows_role_on_row(2, "Publisher") driver.has_contributors_count(3)
def test_updates_track_row_when_track_metadata_change(driver): track = make_track() _ = show_track_list_tab(make_album(tracks=[track])) track.track_title = "Chevere!" track.lead_performer = "Joel Miller" driver.shows_track_details("Chevere!", "Joel Miller")
def test_offers_goto_page_navigation(driver): _ = show_project_screen( make_album(tracks=(make_track(track_title="track 1"), make_track(track_title="track 2"), make_track(track_title="track 3")))) driver.to_page("Project edition") driver.shows_project_edition_page() driver.to_page("1 - track 1") driver.shows_track_edition_page(1) driver.to_page("2 - track 2") driver.shows_track_edition_page(2) driver.to_page("3 - track 3") driver.shows_track_edition_page(3)
def test_unsubscribe_from_track_events_track_removed_from_album(driver): track = make_track() album = make_album(tracks=[track]) _ = show_track_list_tab(album) album.remove_track(0) assert_that(track.metadata_changed.subscribers, empty(), "track 'metadata changed' subscribers")
def test_makes_play_track_request_when_play_context_menu_item_selected(driver): page = show_track_list_tab(make_album(type="mp3", tracks=[make_track(track_title="Spain")])) play_request = ValueMatcherProbe("play track request", has_title("Spain")) page.on_play_track(play_request.received) driver.play_track("Spain") driver.check(play_request)
def test_moves_track_page_when_track_moved(driver): album = make_album(tracks=(make_track(track_title="track 1"), make_track(track_title="track 2"), make_track(track_title="track 3"))) _ = show_project_screen(album) driver.to_page("1 - track 1") driver.shows_track_edition_page(1) album.move_track(from_position=0, to_position=2) driver.shows_track_edition_page(2) driver.to_next_page() driver.shows_track_edition_page(3) driver.to_next_page() driver.shows_track_edition_page(1)
def test_displays_undefined_lyrics_language_in_case_no_language_specified( driver): track = make_track() album = make_album(tracks=[track]) _ = show_page(album, track) driver.shows_language("Undetermined")
def test_updates_the_displayed_page_when_navigating_using_the_arrows(driver): _ = show_project_screen(make_album(tracks=[make_track(track_title="track 1")])) driver.shows_page_in_navigation_combo("Project edition") driver.to_next_page() driver.shows_page_in_navigation_combo("1 - track 1") driver.to_previous_page() driver.shows_page_in_navigation_combo("Project edition")
def test_updates_the_displayed_page_when_navigating_using_the_arrows(driver): _ = show_project_screen( make_album(tracks=[make_track(track_title="track 1")])) driver.shows_page_in_navigation_combo("Project edition") driver.to_next_page() driver.shows_page_in_navigation_combo("1 - track 1") driver.to_previous_page() driver.shows_page_in_navigation_combo("Project edition")
def test_displays_track_details_in_columns(driver): _ = show_track_list_tab(make_album(release_name="Honeycomb", lead_performer="Joel Miller", tracks=[make_track(track_title="Chevere!", bitrate=192000, duration=timedelta(minutes=4, seconds=12).total_seconds())])) driver.shows_track_details("1", "Chevere!", "Joel Miller", "Honeycomb", "192 kbps", "04:12")
def test_creates_chain_of_title_from_track(): track = make_track(lyricist=["Joel Miller"], composer=["John Roney"], publisher=["Effendi Records"]) chain = ChainOfTitle.from_track(track) assert_that(chain.contributors, all_of(has_author_composer("John Roney", has_entry("name", "John Roney")), has_author_composer("Joel Miller", has_entry("name", "Joel Miller")), has_publisher("Effendi Records", has_entry("name", "Effendi Records"))), "The chain of title")
def test_creates_default_chain_of_title_from_metadata(): source_metadata = metadata(lyricist=["Joel Miller"], composer=["John Roney"], publisher=["Effendi Records"]) track = make_track(metadata_from=source_metadata) assert_that(track.chain_of_title.contributors, all_of(has_author_composer("John Roney", has_entry("name", "John Roney")), has_author_composer("Joel Miller", has_entry("name", "Joel Miller")), has_publisher("Effendi Records", has_entry("name", "Effendi Records"))), "The chain of title")
def test_updates_context_menu_item_when_playback_state_changes(driver): track = make_track(track_title="Choices") page = show_track_list_tab(make_album(tracks=[track])) driver.select_track("Choices") driver.has_context_menu_item(with_text('Play "Choices"')) page.playback_started(track) driver.has_context_menu_item(with_text('Stop "Choices"')) page.playback_stopped(track) driver.has_context_menu_item(with_text('Play "Choices"'))