def test_maintains_a_list_of_past_projects_in_reverse_order_of_opening():
    history = ProjectHistory()
    history.project_opened(make_project(filename='oldest.tgit'))
    history.project_opened(make_project(filename='previous.tgit'))
    history.project_opened(make_project(filename='latest.tgit'))

    assert_that(history, contains(snapshot_with(path="latest.tgit"),
                                  snapshot_with(path="previous.tgit"),
                                  snapshot_with(path="oldest.tgit")), "past projects")
def test_reorders_history_to_reflect_latest_updates():
    history = ProjectHistory(make_snapshot(path="1.tgit"),
                             make_snapshot(path="2.tgit"),
                             make_snapshot(path="3.tgit"))

    history.project_saved(make_project(filename="2.tgit"))

    assert_that(history, contains(snapshot_with(path="2.tgit"),
                                  snapshot_with(path="1.tgit"),
                                  snapshot_with(path="3.tgit")), "updated project history")
def test_maintains_a_list_of_past_projects_in_reverse_order_of_opening():
    history = ProjectHistory()
    history.project_opened(make_project(filename='oldest.tgit'))
    history.project_opened(make_project(filename='previous.tgit'))
    history.project_opened(make_project(filename='latest.tgit'))

    assert_that(
        history,
        contains(snapshot_with(path="latest.tgit"),
                 snapshot_with(path="previous.tgit"),
                 snapshot_with(path="oldest.tgit")), "past projects")
def test_reorders_history_to_reflect_latest_updates():
    history = ProjectHistory(make_snapshot(path="1.tgit"),
                             make_snapshot(path="2.tgit"),
                             make_snapshot(path="3.tgit"))

    history.project_saved(make_project(filename="2.tgit"))

    assert_that(
        history,
        contains(snapshot_with(path="2.tgit"), snapshot_with(path="1.tgit"),
                 snapshot_with(path="3.tgit")), "updated project 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 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_loads_history_data_from_settings_file_history_group(store, driver):
    driver["history/size"] = 3
    driver["history/1/name"] = "Last"
    driver["history/1/path"] = "last.tgit"
    driver["history/1/type"] = "flac"
    driver["history/2/name"] = "Previous"
    driver["history/2/path"] = "previous.tgit"
    driver["history/2/type"] = "mp3"
    driver["history/3/name"] = "Oldest"
    driver["history/3/path"] = "oldest.tgit"
    driver["history/3/type"] = "mp3"

    history = store.load_history()

    assert_that(history, contains(snapshot_with(name="Last", type="flac", path="last.tgit"),
                                  snapshot_with(name="Previous", type="mp3", path="previous.tgit"),
                                  snapshot_with(name="Oldest", type="mp3", path="oldest.tgit")))
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_updates_history_and_reports_history_change_when_project_changes(subscriber):
    history = ProjectHistory(make_snapshot(path="updated.tgit", name="original"))

    subscriber.should_receive("history_changed").once()
    history.on_history_changed.subscribe(subscriber.history_changed)

    history.project_opened(make_project(filename="updated.tgit", release_name="updated"))

    assert_that(history, contains(snapshot_with(path="updated.tgit", name="updated")), "updated project history")
def test_limits_history_to_last_10_entries():
    history = ProjectHistory()
    for index in range(15):
        history.project_opened(make_project(filename=str(index)))

    assert_that(
        history,
        contains(*(snapshot_with(path=str(index))
                   for index in reversed(range(5, 15)))))
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")
Exemple #12
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")
Exemple #13
0
def tests_loads_history_data_from_settings_file_history_group(store, driver):
    driver["history/size"] = 3
    driver["history/1/name"] = "Last"
    driver["history/1/path"] = "last.tgit"
    driver["history/1/type"] = "flac"
    driver["history/2/name"] = "Previous"
    driver["history/2/path"] = "previous.tgit"
    driver["history/2/type"] = "mp3"
    driver["history/3/name"] = "Oldest"
    driver["history/3/path"] = "oldest.tgit"
    driver["history/3/type"] = "mp3"

    history = store.load_history()

    assert_that(
        history,
        contains(
            snapshot_with(name="Last", type="flac", path="last.tgit"),
            snapshot_with(name="Previous", type="mp3", path="previous.tgit"),
            snapshot_with(name="Oldest", type="mp3", path="oldest.tgit")))
def test_updates_history_and_reports_history_change_when_project_changes(
        subscriber):
    history = ProjectHistory(
        make_snapshot(path="updated.tgit", name="original"))

    subscriber.should_receive("history_changed").once()
    history.on_history_changed.subscribe(subscriber.history_changed)

    history.project_opened(
        make_project(filename="updated.tgit", release_name="updated"))

    assert_that(history,
                contains(snapshot_with(path="updated.tgit", name="updated")),
                "updated project history")
Exemple #15
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")
def test_limits_history_to_last_10_entries():
    history = ProjectHistory()
    for index in range(15):
        history.project_opened(make_project(filename=str(index)))

    assert_that(history, contains(*(snapshot_with(path=str(index)) for index in reversed(range(5, 15)))))