Commit b5f5d04b authored by Tanguy Le Carrour's avatar Tanguy Le Carrour
Browse files

Improve spec readability.

parent e06683de
......@@ -18,25 +18,23 @@ with describe(ExtractSubTracksController):
with before.each as self:
self.interactor = mock.create_autospec(spec=ExtractSubTracksInteractor)
with describe(ExtractSubTracksController.call):
with it("handles good parameters"):
controller = ExtractSubTracksController("a_path", ["1-2"])
with it("handles good parameters"):
controller = ExtractSubTracksController("a_path", ["1-2"])
controller.call(self.interactor)
controller.call(self.interactor)
expect(self.interactor.execute).to.have.been.called_with(
ExtractSubTracksRequest("a_path", [("1", "2")])
)
expect(self.interactor.execute).to.have.been.called_with(
ExtractSubTracksRequest("a_path", [("1", "2")])
)
with it("handles bad parameters"):
controller = ExtractSubTracksController("a_path", ["1~2.3"])
with it("handles bad parameters"):
controller = ExtractSubTracksController("a_path", ["1~2.3"])
controller.call(self.interactor)
controller.call(self.interactor)
expect(self.interactor.execute).to.have.been.called(
ExtractSubTracksRequest("a_path", [("1~2.3", "0")])
)
expect(self.interactor.execute).to.have.been.called(
ExtractSubTracksRequest("a_path", [("1~2.3", "0")])
)
with describe(ExtractSubTracksPresenter):
......
......@@ -11,47 +11,45 @@ from splito.use_cases.extract_sub_tracks import (
from splito.domain.audio_editing.model import Tracks
with describe(ExtractSubTracksInteractor):
with describe("Extract sub-tracks"):
with before.each as self:
self.tracks = mock.create_autospec(spec=Tracks)
self.presenter = mock.create_autospec(spec=ExtractSubTracksPresenter)
with describe(ExtractSubTracksInteractor.execute):
with it("extracts a sub track"):
interactor = ExtractSubTracksInteractor(self.presenter, self.tracks)
request = ExtractSubTracksRequest("a_track.wav", [("1", "2")])
with it("extracts a sub track"):
interactor = ExtractSubTracksInteractor(self.presenter, self.tracks)
request = ExtractSubTracksRequest("a_track.wav", [("1", "2")])
interactor.execute(request)
interactor.execute(request)
expect(self.tracks.__setitem__).to.have.been.called()
expect(self.presenter.sub_track_extracted).to.have.been.called_with(
"a_track.part-1.wav"
)
expect(self.tracks.__setitem__).to.have.been.called()
expect(self.presenter.sub_track_extracted).to.have.been.called_with(
"a_track.part-1.wav"
)
with it("extracts multiple sub tracks"):
interactor = ExtractSubTracksInteractor(self.presenter, self.tracks)
request = ExtractSubTracksRequest("a_track.wav", [("1", "2"), ("3", "4")])
with it("extracts multiple sub tracks"):
interactor = ExtractSubTracksInteractor(self.presenter, self.tracks)
request = ExtractSubTracksRequest("a_track.wav", [("1", "2"), ("3", "4")])
interactor.execute(request)
interactor.execute(request)
expect(self.tracks.__setitem__.call_count).to.eq(2)
expect(self.presenter.sub_track_extracted.call_count).to.eq(2)
expect(self.tracks.__setitem__.call_count).to.eq(2)
expect(self.presenter.sub_track_extracted.call_count).to.eq(2)
with it("handles wrong tracks"):
interactor = ExtractSubTracksInteractor(self.presenter, self.tracks)
request = ExtractSubTracksRequest("a_track.wav", [])
self.tracks.__getitem__.side_effect = KeyError()
with it("handles wrong tracks"):
interactor = ExtractSubTracksInteractor(self.presenter, self.tracks)
request = ExtractSubTracksRequest("a_track.wav", [])
self.tracks.__getitem__.side_effect = KeyError()
interactor.execute(request)
interactor.execute(request)
expect(self.presenter.not_an_audio_track).to.have.been.called()
expect(self.presenter.not_an_audio_track).to.have.been.called()
with it("handles wrong intervals"):
interactor = ExtractSubTracksInteractor(self.presenter, self.tracks)
request = ExtractSubTracksRequest("a_track.wav", [("1", "0")])
with it("handles wrong intervals"):
interactor = ExtractSubTracksInteractor(self.presenter, self.tracks)
request = ExtractSubTracksRequest("a_track.wav", [("1", "0")])
interactor.execute(request)
interactor.execute(request)
expect(self.presenter.wrong_interval).to.have.been.called()
expect(self.presenter.wrong_interval).to.have.been.called()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment