summaryrefslogtreecommitdiffstats
path: root/src/scheduler_brutal_unittest.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/scheduler_brutal_unittest.py')
-rw-r--r--src/scheduler_brutal_unittest.py68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/scheduler_brutal_unittest.py b/src/scheduler_brutal_unittest.py
new file mode 100644
index 0000000..98de2f1
--- /dev/null
+++ b/src/scheduler_brutal_unittest.py
@@ -0,0 +1,68 @@
+import pytest
+import scheduler_brutal
+from scheduler_brutal import SchedulerBrutal as UUT
+from card import Card
+
+# Force HISTORY_DEPTH to simplify testing
+scheduler_brutal.HISTORY_DEPTH = 3
+
+#--------------------------------------------------------------------------
+#
+#--------------------------------------------------------------------------
+
+#--------------------------------------------------------------------------
+#
+#--------------------------------------------------------------------------
+
+#--------------------------------------------------------------------------
+#
+#--------------------------------------------------------------------------
+
+#--------------------------------------------------------------------------
+#
+#--------------------------------------------------------------------------
+
+#--------------------------------------------------------------------------
+#
+#--------------------------------------------------------------------------
+
+#--------------------------------------------------------------------------
+#
+#--------------------------------------------------------------------------
+
+#--------------------------------------------------------------------------
+# State corrections
+#--------------------------------------------------------------------------
+def test_stateWhenCardsChanged():
+ cards = {"0": Card("f", "b"), "1": Card("a", "b")}
+
+ initial_state = {"0": [1, 0, 1], "-1": [0, 0, 0]}
+ expected_state = {"0": [1, 0, 1], "1": [None, None, None]}
+
+ uut = UUT(cards, initial_state)
+
+ assert uut.getState() == expected_state
+
+def test_stateWhenHistoryDepthIncreased():
+ scheduler_brutal.HISTORY_DEPTH = 5
+
+ cards = {"0": Card("f", "b"), "1": Card("a", "b"), "2": Card("new", "new")}
+
+ initial_state = {"0": [1, 0, 1], "1": [0, 0, 0]}
+ expected_state = {"0": [None, None, 1, 0, 1], "1": [None, None, 0, 0, 0], "2": [None] * 5}
+
+ uut = UUT(cards, initial_state)
+
+ assert uut.getState() == expected_state
+
+def test_stateWhenHistoryDepthDecreased():
+ scheduler_brutal.HISTORY_DEPTH = 1
+
+ cards = {"0": Card("f", "b"), "1": Card("a", "b"), "2": Card("new", "new")}
+
+ initial_state = {"0": [1, 0, 0], "1": [0, 0, 1]}
+ expected_state = {"0": [0], "1": [1], "2": [None]}
+
+ uut = UUT(cards, initial_state)
+
+ assert uut.getState() == expected_state