@@ 189-208 (lines=20) @@ | ||
186 | args, kwargs = self.m.send_message.call_args |
|
187 | assert args[1] == self.write.get_bytes_for_set_pos(port, pos, self.m._convert_speed_to_val(speed), max_power) |
|
188 | ||
189 | @given( angle = st.integers(0, 2147483647), |
|
190 | speed = st.integers(-100,100), |
|
191 | port = st.integers(0,255), |
|
192 | cls = st.sampled_from([ExternalMotor, InternalMotor]) |
|
193 | ) |
|
194 | def test_rotate(self, cls, port, angle, speed): |
|
195 | self._create_motor(cls) |
|
196 | self.m.port = port |
|
197 | max_power = 50 |
|
198 | ||
199 | async def child(): |
|
200 | await self.m.rotate(angle, speed, max_power) |
|
201 | ||
202 | async def main(): |
|
203 | t = await spawn(child()) |
|
204 | await t.join() |
|
205 | kernel.run(main) |
|
206 | ||
207 | args, kwargs = self.m.send_message.call_args |
|
208 | assert args[1] == self.write.get_bytes_for_rotate(port, angle, self.m._convert_speed_to_val(speed), max_power) |
|
209 | ||
210 | def test_port(self): |
|
211 | t = InternalMotor('motor', port=InternalMotor.Port.A) |
|
@@ 168-187 (lines=20) @@ | ||
165 | assert self.m.speed == speed+10 |
|
166 | kernel.run(main) |
|
167 | ||
168 | @given( pos = st.integers(-2147483648, 2147483647), |
|
169 | port = st.integers(0,255), |
|
170 | cls = st.sampled_from([ExternalMotor, InternalMotor]) |
|
171 | ) |
|
172 | def test_set_pos(self, cls, port, pos): |
|
173 | self._create_motor(cls) |
|
174 | self.m.port = port |
|
175 | speed = 50 |
|
176 | max_power = 50 |
|
177 | ||
178 | async def child(): |
|
179 | await self.m.set_pos(pos, speed, max_power) |
|
180 | ||
181 | async def main(): |
|
182 | t = await spawn(child()) |
|
183 | await t.join() |
|
184 | kernel.run(main) |
|
185 | ||
186 | args, kwargs = self.m.send_message.call_args |
|
187 | assert args[1] == self.write.get_bytes_for_set_pos(port, pos, self.m._convert_speed_to_val(speed), max_power) |
|
188 | ||
189 | @given( angle = st.integers(0, 2147483647), |
|
190 | speed = st.integers(-100,100), |