forked from projectmesa/mesa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_usersettableparam.py
42 lines (36 loc) · 1.6 KB
/
test_usersettableparam.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
40
41
42
from unittest import TestCase
from mesa.visualization.UserParam import UserSettableParameter
class TestOption(TestCase):
def setUp(self):
self.number_option = UserSettableParameter("number", value=123)
self.checkbox_option = UserSettableParameter("checkbox", value=True)
self.choice_option = UserSettableParameter(
"choice",
value="I am your default choice",
choices=["I am your default choice", "I am your other choice"],
)
self.slider_option = UserSettableParameter(
"slider", value=123, min_value=100, max_value=200
)
def test_number(self):
assert self.number_option.value == 123
self.number_option.value = 321
assert self.number_option.value == 321
def test_checkbox(self):
assert self.checkbox_option.value
self.checkbox_option.value = False
assert not self.checkbox_option.value
def test_choice(self):
assert self.choice_option.value == "I am your default choice"
self.choice_option.value = "I am your other choice"
assert self.choice_option.value == "I am your other choice"
self.choice_option.value = "I am not an available choice"
assert self.choice_option.value == "I am your default choice"
def test_slider(self):
assert self.slider_option.value == 123
self.slider_option.value = 150
assert self.slider_option.value == 150
self.slider_option.value = 0
assert self.slider_option.value == 100
self.slider_option.value = 300
assert self.slider_option.value == 200