summaryrefslogtreecommitdiffstats
path: root/src/scheduler_brutal_unittest.py
diff options
context:
space:
mode:
authorEddy Pedroni <epedroni@pm.me>2024-09-24 07:17:41 +0200
committerEddy Pedroni <epedroni@pm.me>2024-09-24 07:19:55 +0200
commitc644f52839fe320bf4c8c21661ae8534fd60b37d (patch)
tree870e74fda36bba298b62eba5e4c145506496fe06 /src/scheduler_brutal_unittest.py
parent22bfa00d56233ddb93394b23313efb7c2fcebbc8 (diff)
Refactor Card out of parser.py, implement brutal scheduler constructor
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