示例#1
0
 def test_counterclockwise(self):
     p = {"map": [[[0, 0, 0]]], "counterclockwise": True}
     assert sensehat_listener.validSpinPost(p)
     p = {"map": [[[0, 0, 0]]], "counterclockwise": False}
     assert sensehat_listener.validSpinPost(p)
     p = {"map": [[[0, 0, 0]]], "counterclockwise": "str"}
     assert not sensehat_listener.validSpinPost(p)
     p = {"map": [[[0, 0, 0]]], "counterclockwise": {}}
     assert not sensehat_listener.validSpinPost(p)
示例#2
0
 def test_extra_keys(self):
     p = {"map": [[[0, 0, 0]]], "badkey": 0.1}
     assert not sensehat_listener.validSpinPost(p)
     p = {
         "map": [[[0, 0, 0]]],
         "loops": 1,
         "delay": 1,
         "counterclockwise": True,
         "badkey": True
     }
     assert not sensehat_listener.validSpinPost(p)
示例#3
0
 def test_delay_range(self):
     p = {"map": [[[0, 0, 0]]], "delay": 0}
     assert sensehat_listener.validSpinPost(p)
     p = {"map": [[[0, 0, 0]]], "delay": 1}
     assert sensehat_listener.validSpinPost(p)
     p = {"map": [[[0, 0, 0]]], "delay": 0.5}
     assert sensehat_listener.validSpinPost(p)
     p = {"map": [[[0, 0, 0]]], "delay": -0.5}
     assert not sensehat_listener.validSpinPost(p)
     p = {"map": [[[0, 0, 0]]], "delay": 2}
     assert not sensehat_listener.validSpinPost(p)
示例#4
0
 def test_loops(self):
     p = {"map": [[[0, 0, 0]]], "loops": 0}
     assert sensehat_listener.validSpinPost(p)
     p = {"map": [[[0, 0, 0]]], "loops": 1}
     assert sensehat_listener.validSpinPost(p)
     p = {"map": [[[0, 0, 0]]], "loops": 20}
     assert sensehat_listener.validSpinPost(p)
     p = {"map": [[[0, 0, 0]]], "loops": 0.5}
     assert not sensehat_listener.validSpinPost(p)
     p = {"map": [[[0, 0, 0]]], "loops": -0.5}
     assert not sensehat_listener.validSpinPost(p)
示例#5
0
 def test_all_keys(self):
     p = {
         "map": [[[0, 0, 0]]],
         "loops": 1,
         "delay": 1,
         "counterclockwise": True
     }
     assert sensehat_listener.validSpinPost(p)
示例#6
0
 def test_bad_value_types(self):
     p = {"map": {}, "loops": 1, "delay": 1, "counterclockwise": True}
     assert not sensehat_listener.validSpinPost(p)
     p = {
         "map": [[[0, 0, 0]]],
         "loops": "0.1",
         "delay": 1,
         "counterclockwise": True
     }
     assert not sensehat_listener.validSpinPost(p)
     p = {
         "map": [[[0, 0, 0]]],
         "loops": 1,
         "delay": "str",
         "counterclockwise": True
     }
     assert not sensehat_listener.validSpinPost(p)
     p = {
         "map": [[[0, 0, 0]]],
         "loops": 1,
         "delay": 1,
         "counterclockwise": "True"
     }
     assert not sensehat_listener.validSpinPost(p)
示例#7
0
 def test_missing_required_keys(self):
     p = {"loops": 1, "delay": 1, "counterclockwise": True}
     assert not sensehat_listener.validSpinPost(p)
     p = {"delay": 1, "counterclockwise": True}
     assert not sensehat_listener.validSpinPost(p)
     p = {"loops": 1, "counterclockwise": True}
     assert not sensehat_listener.validSpinPost(p)
     p = {"loops": 1, "delay": 1}
     assert not sensehat_listener.validSpinPost(p)
     p = {"loops": 1}
     assert not sensehat_listener.validSpinPost(p)
     p = {"delay": 1}
     assert not sensehat_listener.validSpinPost(p)
     p = {"counterclockwise": True}
     assert not sensehat_listener.validSpinPost(p)
示例#8
0
 def test_minimal_case(self):
     p = {"map": [[[0, 0, 0]]]}
     assert sensehat_listener.validSpinPost(p)