aboutsummaryrefslogtreecommitdiffstats
path: root/abcontroller_unittest.py
diff options
context:
space:
mode:
Diffstat (limited to 'abcontroller_unittest.py')
-rw-r--r--abcontroller_unittest.py36
1 files changed, 12 insertions, 24 deletions
diff --git a/abcontroller_unittest.py b/abcontroller_unittest.py
index 6e6e779..fbe7ae1 100644
--- a/abcontroller_unittest.py
+++ b/abcontroller_unittest.py
@@ -5,15 +5,7 @@ TCase = namedtuple("TCase", ["currentPosition", "requestedPosition"])
AB = namedtuple("AB", ["a", "b"])
abLimits = AB(0.2, 0.4)
-def checkLimits(uut, aLimit, bLimit, fail=False):
- tests = [
- TCase(aLimit - 0.1, None),
- TCase(aLimit, None),
- TCase(bLimit - 0.1, None),
- TCase(bLimit, None),
- TCase(bLimit + 0.1, aLimit if not fail else None)
- ]
-
+def _checkLimits(uut, tests):
requestedPosition = None
def callback(newPosition):
nonlocal requestedPosition
@@ -28,26 +20,23 @@ def checkLimits(uut, aLimit, bLimit, fail=False):
uut._setPositionCallback = originalCallback
+def checkLimits(uut, aLimit, bLimit, fail=False):
+ tests = [
+ TCase(aLimit - 0.1, None),
+ TCase(aLimit, None),
+ TCase(bLimit - 0.1, None),
+ TCase(bLimit, None),
+ TCase(bLimit + 0.1, aLimit if not fail else None)
+ ]
+ _checkLimits(uut, tests)
+
def checkDefaultLimits(uut):
tests = [
TCase(0.0, None),
TCase(0.1, 0.0),
TCase(0.5, 0.0)
]
-
- requestedPosition = None
- def callback(newPosition):
- nonlocal requestedPosition
- requestedPosition = newPosition
-
- originalCallback = uut._setPositionCallback
- uut._setPositionCallback = callback
-
- for t in tests:
- uut.positionChanged(t.currentPosition)
- assert requestedPosition == t.requestedPosition
-
- uut._setPositionCallback = originalCallback
+ _checkLimits(uut, tests)
def test_oneSetOfLimits():
song = "/path/to/song"
@@ -210,7 +199,6 @@ def test_setTemporaryLimitsWithCurrentSong():
uut.setLimits(l.a, l.b)
checkLimits(uut, l.a, l.b)
-
def test_defaultBehaviour():
uut = ABController()
checkDefaultLimits(uut)