Skip to content

Commit

Permalink
new tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pomponchik committed Apr 3, 2024
1 parent 8fab5c0 commit da17ed0
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/units/test_metronome.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

from metronomes import Metronome

from metronomes.errors import RunStoppedMetronomeError, RunAlreadyStartedMetronomeError, StopNotStartedMetronomeError, StopStoppedMetronomeError


@pytest.mark.parametrize(
'duration',
Expand Down Expand Up @@ -50,3 +52,41 @@ def test_alternation_of_sleep_and_callback():
assert action == 1
else:
assert action == 2


def test_start_started():
metronome = Metronome(0.0001, lambda: None)

metronome.start()

with pytest.raises(RunAlreadyStartedMetronomeError, match=full_match('The metronome has already been launched.')):
metronome.start()

metronome.stop()


def test_stop_stopped():
metronome = Metronome(0.0001, lambda: None)

metronome.start()
metronome.stop()

with pytest.raises(StopStoppedMetronomeError, match=full_match("You've already stopped this metronome, it's impossible to do it twice.")):
metronome.stop()


def test_start_stopped():
metronome = Metronome(0.0001, lambda: None)

metronome.start()
metronome.stop()

with pytest.raises(RunStoppedMetronomeError, match=full_match('Metronomes are disposable, you cannot restart a stopped metronome.')):
metronome.start()


def test_stop_not_started():
metronome = Metronome(0.0001, lambda: None)

with pytest.raises(StopNotStartedMetronomeError, match=full_match("You can't stop a metronome that hasn't been started yet.")):
metronome.stop()

0 comments on commit da17ed0

Please sign in to comment.