October 2016
Intermediate to advanced
418 pages
9h 52m
English
Now, we will write additional unit tests to improve the testing coverage. Specifically, we will write unit tests related to the hexacopter motor and the altimeter. Open the existing test_hexacopter.py file and insert the following lines after the last line. The code file for the sample is included in the restful_python_chapter_10_03 folder:
def test_set_and_get_hexacopter_motor_speed(self): """ Ensure we can set and get the hexacopter's motor speed """ patch_args = {'motor_speed': 700} patch_response = self.fetch( '/hexacopters/1', method='PATCH', body=json.dumps(patch_args)) self.assertEqual(patch_response.code, status.HTTP_200_OK) get_response = self.fetch( '/hexacopters/1', method='GET') self.assertEqual(get_response.code, ...