def query_enum_property(): print r"==query_enum_property==" client.send_data_to_server(r"ResetDataSource").get() data = client.get_data_from_server(r"Products(5)/SkinColor").get() print len(data) == 1 skinColor = odata_client_python.to_enum_value(data[0]) print skinColor.to_string() == r"Red"
def action_of_enum_value(): print r"==action_of_enum_value==" client.send_data_to_server(r"ResetDataSource").get() product_user_access = r"Products(5)/UserAccess" user_access_value = odata_client_python.to_enum_value(client.get_data_from_server(product_user_access).get()[0]) print user_access_value.to_string() == r"None" model = client.get_model().get() new_access = odata_client_python.odata_enum_value(model.find_enum_type(r"AccessLevel"), r"ReadWrite") parameters = odata_client_python.vector_odata_parameter() parameters.push_back(odata_client_python.odata_parameter(r"accessRight", new_access)) returned_values = odata_client_python.vector_odata_value() client.send_data_to_server(r"Products(5)/Microsoft.Test.OData.Services.ODataWCFService.AddAccessRight", parameters, returned_values).get() print len(returned_values) == 1 returned_value = returned_values[0]; user_access_value = odata_client_python.to_enum_value(client.get_data_from_server(product_user_access).get()[0]) print user_access_value.to_string() == r"ReadWrite" returned_enum_value = odata_client_python.to_enum_value(returned_value) print returned_enum_value.to_string() == r"ReadWrite"
def query_enum_in_entity(): print r"==query_enum_in_entity==" client.send_data_to_server(r"ResetDataSource").get() entities = client.get_entities(r"Products").get() firstEntity = entities[0] skinColor = odata_client_python.odata_value() firstEntity.get_property_value(r"SkinColor", skinColor) print skinColor.get_value_type().get_type_kind() == odata_client_python.Enum skinColorEnum = odata_client_python.to_enum_value(skinColor) print skinColorEnum.to_string() == r"Red"
def query_enum_in_entity(): print r"==query_enum_in_entity==" client.send_data_to_server(r"ResetDataSource").get() entities = client.get_entities(r"Products").get() firstEntity = entities[0] skinColor = odata_client_python.odata_value() firstEntity.get_property_value(r"SkinColor", skinColor) print skinColor.get_value_type().get_type_kind( ) == odata_client_python.Enum skinColorEnum = odata_client_python.to_enum_value(skinColor) print skinColorEnum.to_string() == r"Red"
def update_enum_property(): print r"==update_enum_property==" client.send_data_to_server(r"ResetDataSource").get() model = client.get_model().get() old_data = client.get_data_from_server(r"Products(5)").get() old_entity = odata_client_python.to_entity_value(old_data[0]) old_value = odata_client_python.odata_value() old_entity.get_property_value(r"UserAccess", old_value) old_enum = odata_client_python.to_enum_value(old_value) print old_enum.to_string() == r"None" access_level_type = model.find_enum_type(r"AccessLevel") new_access = odata_client_python.odata_enum_value(access_level_type, r"ReadWrite") old_entity.set_value(r"UserAccess", new_access) response_code = client.patch_entity(r"Products", old_entity).get() print response_code == 204 new_data = client.get_data_from_server(r"Products(5)").get() new_entity = odata_client_python.to_entity_value(new_data[0]) new_value = odata_client_python.odata_value() new_entity.get_property_value(r"UserAccess", new_value) new_enum = odata_client_python.to_enum_value(new_value) print new_enum.to_string() == r"ReadWrite"
def query_enum(self, query_ex, ret_type): if self._client is None: return [] values = self._client.get_data_from_server(query_ex).get() ret = [] for value in values: if value is None: continue enum_value = odata_client_python.to_enum_value(value) if enum_value is None: continue val = ret_type.get_enum_value_from_string(enum_value.to_string()) ret.append(val) return ret
def operation_query_enum(self, query_ex, parameters, is_function, ret_type): if self._client is None: return None ret_values = odata_client_python.vector_odata_value() self._client.send_data_to_server(query_ex, parameters, ret_values, odata_client_python.HTTP_GET if is_function else odata_client_python.HTTP_POST).get() ret = [] for value in ret_values: if value is None: continue enum_value = odata_client_python.to_enum_value(value) if enum_value is None: continue val = ret_type.get_enum_value_from_string(enum_value.to_string()) ret.append(val) return ret
def action_of_enum_value(): print r"==action_of_enum_value==" client.send_data_to_server(r"ResetDataSource").get() product_user_access = r"Products(5)/UserAccess" user_access_value = odata_client_python.to_enum_value( client.get_data_from_server(product_user_access).get()[0]) print user_access_value.to_string() == r"None" model = client.get_model().get() new_access = odata_client_python.odata_enum_value( model.find_enum_type(r"AccessLevel"), r"ReadWrite") parameters = odata_client_python.vector_odata_parameter() parameters.push_back( odata_client_python.odata_parameter(r"accessRight", new_access)) returned_values = odata_client_python.vector_odata_value() client.send_data_to_server( r"Products(5)/Microsoft.Test.OData.Services.ODataWCFService.AddAccessRight", parameters, returned_values).get() print len(returned_values) == 1 returned_value = returned_values[0] user_access_value = odata_client_python.to_enum_value( client.get_data_from_server(product_user_access).get()[0]) print user_access_value.to_string() == r"ReadWrite" returned_enum_value = odata_client_python.to_enum_value(returned_value) print returned_enum_value.to_string() == r"ReadWrite"