def test_clears_previous_history_on_display(driver): page = show_page( make_project_history(make_snapshot(name="1", path="previous.tgit"), make_snapshot(name="2", path="oldest.tgit"))) page.display_project_history( make_project_history(make_snapshot(name="1", path="last.tgit"))) driver.shows_recent_projects(starts_with("1"))
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_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_project_to_open_when_open_action_triggered(driver, using): signal = ValueMatcherProbe("open project", "project.tgit") _ = show_page(make_project_history(make_snapshot(name="project", path="project.tgit")), on_load_project=signal.received) driver.open_recent_project(starts_with("project"), using=using) driver.check(signal)
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 show_page(project_history=make_project_history(), select_project=ignore, show_load_error=ignore, **handlers): page = make_welcome_page(project_history, select_project, show_load_error, **handlers) show_(page) return page
def test_loads_project_history_from_store_and_then_reports_to_history_when_a_project_is_opened_or_saved(studio, store): history = make_project_history() store.should_receive("load_history").and_return(history) studio.on_project_opened.should_receive("subscribe").with_args(history.project_opened).once() studio.on_project_saved.should_receive("subscribe").with_args(history.project_saved).once() assert_that(load_from(studio, store), is_(history), "history")
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_displays_project_history(driver): _ = show_page( make_project_history( make_snapshot(name="Last", type_="mp3", path="last.tgit"), make_snapshot(name="Previous", type_="flac", path="previous.tgit"), make_snapshot(name="Oldest", type_="mp3", path="oldest.tgit"))) driver.shows_recent_projects("Last (MP3)", "Previous (FLAC)", "Oldest (MP3)")
def test_signals_project_to_open_when_open_action_triggered(driver, using): signal = ValueMatcherProbe("open project", "project.tgit") _ = show_page(make_project_history( make_snapshot(name="project", path="project.tgit")), on_load_project=signal.received) driver.open_recent_project(starts_with("project"), using=using) driver.check(signal)
def test_loads_project_history_from_store_and_then_reports_to_history_when_a_project_is_opened_or_saved( studio, store): history = make_project_history() store.should_receive("load_history").and_return(history) studio.on_project_opened.should_receive("subscribe").with_args( history.project_opened).once() studio.on_project_saved.should_receive("subscribe").with_args( history.project_saved).once() assert_that(load_from(studio, store), is_(history), "history")
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")
def tests_stores_history_data_under_history_group_in_settings_file(store, driver): store.store_history(make_project_history(make_snapshot(name="Last", type_="flac", path="last.tgit"), make_snapshot(name="Previous", type_="mp3", path="previous.tgit"), make_snapshot(name="Oldest", type_="mp3", path="oldest.tgit"))) driver.has_stored("history/size", 3) driver.has_stored("history/1/name", "Last") driver.has_stored("history/1/path", "last.tgit") driver.has_stored("history/1/type", "flac") driver.has_stored("history/2/name", "Previous") driver.has_stored("history/2/path", "previous.tgit") driver.has_stored("history/2/type", "mp3") driver.has_stored("history/3/name", "Oldest") driver.has_stored("history/3/path", "oldest.tgit") driver.has_stored("history/3/type", "mp3")
def tests_stores_history_data_under_history_group_in_settings_file( store, driver): store.store_history( make_project_history( make_snapshot(name="Last", type_="flac", path="last.tgit"), make_snapshot(name="Previous", type_="mp3", path="previous.tgit"), make_snapshot(name="Oldest", type_="mp3", path="oldest.tgit"))) driver.has_stored("history/size", 3) driver.has_stored("history/1/name", "Last") driver.has_stored("history/1/path", "last.tgit") driver.has_stored("history/1/type", "flac") driver.has_stored("history/2/name", "Previous") driver.has_stored("history/2/path", "previous.tgit") driver.has_stored("history/2/type", "mp3") driver.has_stored("history/3/name", "Oldest") driver.has_stored("history/3/path", "oldest.tgit") driver.has_stored("history/3/type", "mp3")
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")
def test_disables_open_project_when_no_project_selected(driver): _ = show_page(make_project_history(make_snapshot(name="project"))) driver.has_disabled_open_project() driver.select_project(starts_with("project")) driver.has_enabled_open_project()
def show_page(project_history=make_project_history(), select_project=ignore, show_load_error=ignore, **handlers): page = make_welcome_page(project_history, select_project, show_load_error, **handlers) show_(page) return page
def test_displays_project_history(driver): _ = show_page(make_project_history(make_snapshot(name="Last", type_="mp3", path="last.tgit"), make_snapshot(name="Previous", type_="flac", path="previous.tgit"), make_snapshot(name="Oldest", type_="mp3", path="oldest.tgit"))) driver.shows_recent_projects("Last (MP3)", "Previous (FLAC)", "Oldest (MP3)")
def test_clears_previous_history_on_display(driver): page = show_page(make_project_history(make_snapshot(name="1", path="previous.tgit"), make_snapshot(name="2", path="oldest.tgit"))) page.display_project_history(make_project_history(make_snapshot(name="1", path="last.tgit"))) driver.shows_recent_projects(starts_with("1"))
def test_disables_open_project_when_no_project_selected(driver): _ = show_page(make_project_history(make_snapshot(name="project"))) driver.has_disabled_open_project() driver.select_project(starts_with("project")) driver.has_enabled_open_project()