From ebc193873c382bd814730e8ea3032604ebb4a851 Mon Sep 17 00:00:00 2001 From: Eddy Pedroni Date: Wed, 25 Sep 2024 18:35:35 +0200 Subject: Change card ID to string --- src/scheduler_brutal_unittest.py | 52 ++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'src/scheduler_brutal_unittest.py') diff --git a/src/scheduler_brutal_unittest.py b/src/scheduler_brutal_unittest.py index 779d2c3..8dc72fe 100644 --- a/src/scheduler_brutal_unittest.py +++ b/src/scheduler_brutal_unittest.py @@ -10,22 +10,22 @@ scheduler_brutal.HISTORY_DEPTH = 3 # Scheduling behaviour #-------------------------------------------------------------------------- def test_scheduling(): - cards = {id: Card("", "") for id in range(0, 10)} + cards = {str(id): Card("", "") for id in range(0, 10)} state = { - 0: [1, 1, 1], - 1: [0, 0, 0], - 2: [0, 0, 1], - 3: [1, 0, 0], - - 4: [None, None, 1 ], - 5: [None, 1, None], - 6: [1, None, None], - 7: [None, None, 0 ], - 8: [0, 0, None], - 9: [None, None, None], + "0": [1, 1, 1], + "1": [0, 0, 0], + "2": [0, 0, 1], + "3": [1, 0, 0], + + "4": [None, None, 1 ], + "5": [None, 1, None], + "6": [1, None, None], + "7": [None, None, 0 ], + "8": [0, 0, None], + "9": [None, None, None], } - expected_priority = [9, 6, 5, 7, 8, 4, 1, 3, 2, 0] + expected_priority = ["9", "6", "5", "7", "8", "4", "1", "3", "2", "0"] uut = UUT(cards, state) @@ -36,14 +36,14 @@ def test_scheduling(): # State update #-------------------------------------------------------------------------- def test_stateUpdate(): - cards = {0: Card("f", "b"), 1: Card("a", "b"), 2: Card("c", "d")} - state = {0: [1, 0, 1], 1: [1, 0, 0], 2: [0, 0, 1]} + cards = {"0": Card("f", "b"), "1": Card("a", "b"), "2": Card("c", "d")} + state = {"0": [1, 0, 1], "1": [1, 0, 0], "2": [0, 0, 1]} uut = UUT(cards, state) # Unknown IDs in the result are silently ignored - result = {0: 1, 1: 0, 3: 0} - expected_state = {0: [0, 1, 1], 1: [0, 0, 0], 2: [0, 1, None]} + result = {"0": 1, "1": 0, "3": 0} + expected_state = {"0": [0, 1, 1], "1": [0, 0, 0], "2": [0, 1, None]} uut.update(result) @@ -53,10 +53,10 @@ def test_stateUpdate(): # State corrections #-------------------------------------------------------------------------- def test_stateWhenCardsChanged(): - cards = {0: Card("f", "b"), 1: Card("a", "b")} + 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]} + initial_state = {"0": [1, 0, 1], "2": [0, 0, 0]} + expected_state = {"0": [1, 0, 1], "1": [None, None, None]} uut = UUT(cards, initial_state) @@ -65,10 +65,10 @@ def test_stateWhenCardsChanged(): def test_stateWhenHistoryDepthIncreased(): scheduler_brutal.HISTORY_DEPTH = 5 - cards = {0: Card("f", "b"), 1: Card("a", "b"), 2: Card("new", "new")} + 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} + 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) @@ -77,10 +77,10 @@ def test_stateWhenHistoryDepthIncreased(): def test_stateWhenHistoryDepthDecreased(): scheduler_brutal.HISTORY_DEPTH = 1 - cards = {0: Card("f", "b"), 1: Card("a", "b"), 2: Card("new", "new")} + 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]} + initial_state = {"0": [1, 0, 0], "1": [0, 0, 1]} + expected_state = {"0": [0], "1": [1], "2": [None]} uut = UUT(cards, initial_state) -- cgit v1.2.3