Пример #1
0
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")
Пример #2
0
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")
Пример #3
0
def test_signals_when_project_created(studio, subscriber):
    new_project = make_project()

    subscriber.should_receive("project_opened").with_args(new_project).once()
    studio.on_project_opened.subscribe(subscriber.project_opened)

    studio.project_created(new_project)
Пример #4
0
def test_signals_when_project_created(studio, subscriber):
    new_project = make_project()

    subscriber.should_receive("project_opened").with_args(new_project).once()
    studio.on_project_opened.subscribe(subscriber.project_opened)

    studio.project_created(new_project)
Пример #5
0
def test_saves_project_to_catalog_and_then_reports_save_success_to_studio(studio, catalog):
    project_to_save = make_project()

    catalog.should_receive("save_project").with_args(project_to_save).once().ordered()
    studio.should_receive("project_saved").with_args(project_to_save).once().ordered()

    project.save_to(studio, catalog=catalog)(project_to_save)
Пример #6
0
def test_keeps_track_of_current_project(studio):
    current_project = make_project()
    studio.project_loaded(current_project)
    assert_that(studio.current_project, is_(current_project),
                "current project loaded")
    studio.project_closed(current_project)
    assert_that(studio.current_project, is_(none()), "current project closed")
Пример #7
0
def test_signals_when_project_closed(studio, subscriber):
    closed_project = make_project()

    subscriber.should_receive("project_closed").with_args(closed_project).once()
    studio.on_project_closed.subscribe(subscriber.project_closed)

    studio.project_closed(closed_project)
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"))
Пример #9
0
def test_signals_when_project_closed(studio, subscriber):
    closed_project = make_project()

    subscriber.should_receive("project_closed").with_args(
        closed_project).once()
    studio.on_project_closed.subscribe(subscriber.project_closed)

    studio.project_closed(closed_project)
Пример #10
0
def test_loads_project_from_catalog_and_then_reports_load_success_to_studio(
        studio, catalog):
    project_to_load = make_project()
    catalog.should_receive("load_project").with_args(
        "/path/to/project.tgit").and_return(project_to_load)
    studio.should_receive("project_loaded").with_args(project_to_load).once()

    project.load_to(studio,
                    from_catalog=catalog)(filename="/path/to/project.tgit")
Пример #11
0
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_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"))
Пример #13
0
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)))))
Пример #14
0
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")
Пример #15
0
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")
Пример #16
0
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")
Пример #17
0
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")
Пример #18
0
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")
Пример #19
0
def test_snapshots_project_type():
    project = make_project(type_="flac")
    snapshot = ProjectSnapshot.of(project)
    project.type = "mp3"
    assert_that(snapshot.type, equal_to("flac"), "snapshot's type")
Пример #20
0
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)))))
Пример #21
0
def test_loads_project_from_catalog_and_then_reports_load_success_to_studio(studio, catalog):
    project_to_load = make_project()
    catalog.should_receive("load_project").with_args("/path/to/project.tgit").and_return(project_to_load)
    studio.should_receive("project_loaded").with_args(project_to_load).once()

    project.load_to(studio, from_catalog=catalog)(filename="/path/to/project.tgit")
Пример #22
0
def test_snapshots_project_type():
    project = make_project(type_="flac")
    snapshot = ProjectSnapshot.of(project)
    project.type = "mp3"
    assert_that(snapshot.type, equal_to("flac"), "snapshot's type")
Пример #23
0
def test_snapshots_project_name():
    project = make_project(release_name="Original")
    snapshot = ProjectSnapshot.of(project)
    project.release_name = "Updated"
    assert_that(snapshot.name, equal_to("Original"), "snapshot's name")
Пример #24
0
def test_keeps_track_of_current_project(studio):
    current_project = make_project()
    studio.project_loaded(current_project)
    assert_that(studio.current_project, is_(current_project), "current project loaded")
    studio.project_closed(current_project)
    assert_that(studio.current_project, is_(none()), "current project closed")
Пример #25
0
def test_snapshots_project_filename():
    project = make_project(filename="project.tgit")
    snapshot = ProjectSnapshot.of(project)
    assert_that(snapshot.path, equal_to("project.tgit"), "snapshot's path")
Пример #26
0
def test_snapshots_project_name():
    project = make_project(release_name="Original")
    snapshot = ProjectSnapshot.of(project)
    project.release_name = "Updated"
    assert_that(snapshot.name, equal_to("Original"), "snapshot's name")
Пример #27
0
def test_snapshots_project_filename():
    project = make_project(filename="project.tgit")
    snapshot = ProjectSnapshot.of(project)
    assert_that(snapshot.path, equal_to("project.tgit"), "snapshot's path")