forked from ArchipelagoMW/Archipelago
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest_player_options.py
39 lines (33 loc) · 1.83 KB
/
test_player_options.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import unittest
import Generate
class TestPlayerOptions(unittest.TestCase):
def test_update_weights(self):
original_weights = {
"scalar_1": 50,
"scalar_2": 25,
"list_1": ["string"],
"dict_1": {"option_a": 50, "option_b": 50},
"dict_2": {"option_f": 50},
"set_1": {"option_c"}
}
# test that we don't allow +merge syntax on scalar variables
with self.assertRaises(BaseException):
Generate.update_weights(original_weights, {"+scalar_1": 0}, "Tested", "")
new_weights = Generate.update_weights(original_weights, {"scalar_2": 0,
"+list_1": ["string_2"],
"+dict_1": {"option_b": 0, "option_c": 50},
"+set_1": {"option_c", "option_d"},
"dict_2": {"option_g": 50},
"+list_2": ["string_3"]},
"Tested", "")
self.assertEqual(new_weights["scalar_1"], 50)
self.assertEqual(new_weights["scalar_2"], 0)
self.assertEqual(new_weights["list_2"], ["string_3"])
self.assertEqual(new_weights["list_1"], ["string", "string_2"])
self.assertEqual(new_weights["dict_1"]["option_a"], 50)
self.assertEqual(new_weights["dict_1"]["option_b"], 50)
self.assertEqual(new_weights["dict_1"]["option_c"], 50)
self.assertNotIn("option_f", new_weights["dict_2"])
self.assertEqual(new_weights["dict_2"]["option_g"], 50)
self.assertEqual(len(new_weights["set_1"]), 2)
self.assertIn("option_d", new_weights["set_1"])