def test_post_user_preferences(self): expected_country = 'UK' response = self.user_preferences_client.post_user_preferences( auth=self.auth, country=expected_country) self.assertIsNotNone( response, 'Response is None. user_name: ' + str(self.user_name)) status_code = ClientUtils.get_response_status_code(response) self.assertEqual( httplib.OK, status_code, 'Got status code: ' + str(status_code) + self.extra_data.get_all()) self.assertTrue( ClientUtils.is_response_body_empty(response), 'Expected empty body in response but got ' + str(ClientUtils.get_response_body(response)) + self.extra_data.get_all()) get_user_preferences_response = self.user_preferences_client.get_user_preferences( auth=self.auth) status_code = ClientUtils.get_response_status_code( get_user_preferences_response) self.assertEqual( httplib.OK, status_code, 'Got status code: ' + str(status_code) + self.extra_data.get_all()) self.extra_data.add_test_data( 'get_user_preferences_response', ClientUtils.get_response_body(get_user_preferences_response)) country = ClientUtils.get_value_from_body( get_user_preferences_response, UserClient.KEY_COUNTRY) self.assertEqual( expected_country, country, 'Expected changed country: ' + str(expected_country) + ' but got: ' + str(country) + self.extra_data.get_all())
def test_post_drawing_preferences(self): file_name = 'test_file_post_drawing_prefs' + str(int(time())) + '.dwg' expected_orth_on = True expected_line_weight_on = False self.extra_data.add_test_data('file name', file_name) created_file_id, msg = TestUtils.create_file( auth=self.auth, file_name=file_name, extra_data=self.extra_data) self.assertIsNotNone(created_file_id, msg + self.extra_data.get_all()) user_specific_drawing_prefs = {} user_specific_drawing_prefs.__setitem__('orthoOn', expected_orth_on) user_specific_drawing_prefs.__setitem__('lineWeightOn', expected_line_weight_on) post_drawing_prefs_response = self.files_management_client.post_drawing_preferences( auth=self.auth, file_id=created_file_id, user_specific_drawing_preferences=user_specific_drawing_prefs) self.assertIsNotNone(post_drawing_prefs_response, 'Response is None' + self.extra_data.get_all()) status_code = ClientUtils.get_response_status_code( post_drawing_prefs_response) self.assertEqual( httplib.NO_CONTENT, status_code, 'Got status code: ' + str(status_code) + self.extra_data.get_all()) self.assertTrue( ClientUtils.is_response_body_empty(post_drawing_prefs_response), 'Expected empty response body but got: ' + str(ClientUtils.get_response_body(post_drawing_prefs_response)) + self.extra_data.get_all()) get_drawing_prefs_response = self.files_management_client.get_drawing_preferences( auth=self.auth, file_id=created_file_id) status_code = ClientUtils.get_response_status_code( get_drawing_prefs_response) self.assertEqual( httplib.OK, status_code, 'Got status code: ' + str(status_code) + self.extra_data.get_all()) self.extra_data.add_test_data( 'get_drawing_preferences response', ClientUtils.get_response_body(get_drawing_prefs_response)) orth_on = ClientUtils.get_value_from_body( response=get_drawing_prefs_response, json_path='userSpecificDrawingPreferences.orthoOn') self.assertEqual( expected_orth_on, orth_on, 'Expected orth_on: ' + str(expected_orth_on) + 'but got: ' + str(orth_on) + self.extra_data.get_all()) line_weight_on = ClientUtils.get_value_from_body( response=get_drawing_prefs_response, json_path='userSpecificDrawingPreferences.lineWeightOn') self.assertEqual( expected_line_weight_on, line_weight_on, 'Expected line_weight_on: ' + str(expected_line_weight_on) + 'but got: ' + str(line_weight_on) + self.extra_data.get_all())