예제 #1
0
 def test_missing_required_keys(self):
     p = {}
     assert not sensehat_listener.validFlashPost(p)
     p = {"loops": 1}
     assert not sensehat_listener.validFlashPost(p)
     p = {"ontime": 1}
     assert not sensehat_listener.validFlashPost(p)
     p = {"offtime": 1}
     assert not sensehat_listener.validFlashPost(p)
     p = {"ontime": 0.1, "offtime": 0.1, "loops": 2}
     assert not sensehat_listener.validFlashPost(p)
예제 #2
0
 def test_extra_keys(self):
     p = {"map": [[[0, 0, 0]]], "badkey": 0.1}
     assert not sensehat_listener.validFlashPost(p)
     p = {
         "map": [[[0, 0, 0]]],
         "ontime": 0.1,
         "offtime": 0.1,
         "loops": 2,
         "badkey": 1
     }
     assert not sensehat_listener.validFlashPost(p)
예제 #3
0
 def test_loops(self):
     p = {"map": [[[0, 0, 0]]], "loops": 0}
     assert sensehat_listener.validFlashPost(p)
     p = {"map": [[[0, 0, 0]]], "loops": 1}
     assert sensehat_listener.validFlashPost(p)
     p = {"map": [[[0, 0, 0]]], "loops": 20}
     assert sensehat_listener.validFlashPost(p)
     p = {"map": [[[0, 0, 0]]], "loops": 0.5}
     assert not sensehat_listener.validFlashPost(p)
     p = {"map": [[[0, 0, 0]]], "loops": -0.5}
     assert not sensehat_listener.validFlashPost(p)
예제 #4
0
 def test_offtime_range(self):
     p = {"map": [[[0, 0, 0]]], "offtime": 0}
     assert sensehat_listener.validFlashPost(p)
     p = {"map": [[[0, 0, 0]]], "offtime": 1}
     assert sensehat_listener.validFlashPost(p)
     p = {"map": [[[0, 0, 0]]], "offtime": 0.5}
     assert sensehat_listener.validFlashPost(p)
     p = {"map": [[[0, 0, 0]]], "offtime": -0.5}
     assert not sensehat_listener.validFlashPost(p)
     p = {"map": [[[0, 0, 0]]], "offtime": 2}
     assert not sensehat_listener.validFlashPost(p)
예제 #5
0
 def test_bad_value_types(self):
     p = {"map": {}, "ontime": 0.1, "offtime": 0.1, "loops": 2}
     assert not sensehat_listener.validFlashPost(p)
     p = {"map": [[[0, 0, 0]]], "ontime": "str", "offtime": 0.1, "loops": 2}
     assert not sensehat_listener.validFlashPost(p)
     p = {"map": [[[0, 0, 0]]], "ontime": 0.1, "offtime": "str", "loops": 2}
     assert not sensehat_listener.validFlashPost(p)
     p = {
         "map": [[[0, 0, 0]]],
         "ontime": 0.1,
         "offtime": 0.1,
         "loops": "str"
     }
     assert not sensehat_listener.validFlashPost(p)
예제 #6
0
 def test_all_keys(self):
     p = {"map": [[[0, 0, 0]]], "ontime": 0.1, "offtime": 0.1, "loops": 2}
     assert sensehat_listener.validFlashPost(p)
예제 #7
0
 def test_minimal_case(self):
     p = {"map": [[[0, 0, 0]]]}
     assert sensehat_listener.validFlashPost(p)