def action_of_complex_value():
    print r"==action_of_complex_value=="
    client.send_data_to_server(r"ResetDataSource").get()
    home_address = r"People(1)/HomeAddress"
    home_address_value = odata_client_python.to_complex_value(client.get_data_from_server(home_address).get()[0])
    property_value = odata_client_python.odata_value()
    home_address_value.get_property_value(r"City", property_value)
    print odata_client_python.to_primitive_value(property_value).to_string() == r"Tokyo"
    model = client.get_model().get()
    address_type = model.find_complex_type(r"Address")
    new_address1 = odata_client_python.odata_complex_value(address_type)
    new_address1.set_value(r"City", r"Shanghai")
    new_address1.set_value(r"PostalCode", r"200000")
    new_address1.set_value(r"Street", r"Zixing Road")
    addresses = odata_client_python.odata_collection_value(odata_client_python.edm_collection_type(r"AddressCollection", address_type))
    addresses.add_collection_value(new_address1)
    parameters = odata_client_python.vector_odata_parameter()
    parameters.push_back(odata_client_python.odata_parameter(r"addresses", addresses))
    parameters.push_back(odata_client_python.odata_parameter(r"index", odata_client_python.odata_primitive_value.make_primitive_value(0)))
    returned_values = odata_client_python.vector_odata_value()
    client.send_data_to_server(r"People(1)/Microsoft.Test.OData.Services.ODataWCFService.ResetAddress", parameters, returned_values).get()
    print len(returned_values) == 1
    returned_value = returned_values[0]
    home_address_value = odata_client_python.to_complex_value(client.get_data_from_server(home_address).get()[0])
    home_address_value.get_property_value(r"City", property_value)
    print odata_client_python.to_primitive_value(property_value).to_string() == r"Shanghai"
    returned_entity_value = odata_client_python.to_entity_value(returned_value)
    returned_entity_value.get_property_value(r"HomeAddress", property_value)
    odata_client_python.to_complex_value(property_value).get_property_value(r"City", property_value)
    print odata_client_python.to_primitive_value(property_value).to_string() == r"Shanghai"
def action_of_primitive_value():
    print r"==action_of_primitive_value=="
    client.send_data_to_server(r"ResetDataSource").get()
    company_revenue_path = r"Company/Revenue"
    revenue_odata_value = client.get_data_from_server(
        company_revenue_path).get()[0]
    revenue_primitive_value = odata_client_python.to_primitive_value(
        revenue_odata_value)
    revenue = eval(revenue_primitive_value.to_string())
    print revenue == 100000
    parameters = odata_client_python.vector_odata_parameter()
    parameters.push_back(
        odata_client_python.odata_parameter(
            r"IncreaseValue",
            odata_client_python.odata_primitive_value.make_primitive_value(
                100000)))
    returned_values = odata_client_python.vector_odata_value()
    client.send_data_to_server(
        r"Company/Microsoft.Test.OData.Services.ODataWCFService.IncreaseRevenue",
        parameters, returned_values).get()
    print len(returned_values) == 1
    returned_value = returned_values[0]
    revenue_odata_value = client.get_data_from_server(
        company_revenue_path).get()[0]
    revenue_primitive_value = odata_client_python.to_primitive_value(
        revenue_odata_value)
    revenue = eval(revenue_primitive_value.to_string())
    print revenue == 200000
    returned_primitive_value = odata_client_python.to_primitive_value(
        returned_value)
    print eval(returned_primitive_value.to_string()) == 200000
def action_of_complex_value():
    print r"==action_of_complex_value=="
    client.send_data_to_server(r"ResetDataSource").get()
    home_address = r"People(1)/HomeAddress"
    home_address_value = odata_client_python.to_complex_value(
        client.get_data_from_server(home_address).get()[0])
    property_value = odata_client_python.odata_value()
    home_address_value.get_property_value(r"City", property_value)
    print odata_client_python.to_primitive_value(
        property_value).to_string() == r"Tokyo"
    model = client.get_model().get()
    address_type = model.find_complex_type(r"Address")
    new_address1 = odata_client_python.odata_complex_value(address_type)
    new_address1.set_value(r"City", r"Shanghai")
    new_address1.set_value(r"PostalCode", r"200000")
    new_address1.set_value(r"Street", r"Zixing Road")
    addresses = odata_client_python.odata_collection_value(
        odata_client_python.edm_collection_type(r"AddressCollection",
                                                address_type))
    addresses.add_collection_value(new_address1)
    parameters = odata_client_python.vector_odata_parameter()
    parameters.push_back(
        odata_client_python.odata_parameter(r"addresses", addresses))
    parameters.push_back(
        odata_client_python.odata_parameter(
            r"index",
            odata_client_python.odata_primitive_value.make_primitive_value(0)))
    returned_values = odata_client_python.vector_odata_value()
    client.send_data_to_server(
        r"People(1)/Microsoft.Test.OData.Services.ODataWCFService.ResetAddress",
        parameters, returned_values).get()
    print len(returned_values) == 1
    returned_value = returned_values[0]
    home_address_value = odata_client_python.to_complex_value(
        client.get_data_from_server(home_address).get()[0])
    home_address_value.get_property_value(r"City", property_value)
    print odata_client_python.to_primitive_value(
        property_value).to_string() == r"Shanghai"
    returned_entity_value = odata_client_python.to_entity_value(returned_value)
    returned_entity_value.get_property_value(r"HomeAddress", property_value)
    odata_client_python.to_complex_value(property_value).get_property_value(
        r"City", property_value)
    print odata_client_python.to_primitive_value(
        property_value).to_string() == r"Shanghai"
def function_return_collection_of_complex_value():
    print r"==function_return_collection_of_complex_value=="
    client.send_data_to_server(r"ResetDataSource").get()
    product_details_path = r"Products(5)/Microsoft.Test.OData.Services.ODataWCFService.GetProductDetails"
    parameters = odata_client_python.vector_odata_parameter()
    parameters.push_back(odata_client_python.odata_parameter(r"count", odata_client_python.odata_primitive_value.make_primitive_value(3)))
    returned_values = odata_client_python.vector_odata_value()
    client.send_data_to_server(product_details_path, parameters, returned_values, odata_client_python.HTTP_GET).get()
    print len(returned_values) == 3
    detail1 = odata_client_python.to_entity_value(returned_values[0])
    property_value = odata_client_python.odata_value()
    detail1.get_property_value(r"ProductID", property_value)
    primitive_value = odata_client_python.to_primitive_value(property_value)
    print eval(primitive_value.to_string()) == 5
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 function_return_collection_of_complex_value():
    print r"==function_return_collection_of_complex_value=="
    client.send_data_to_server(r"ResetDataSource").get()
    product_details_path = r"Products(5)/Microsoft.Test.OData.Services.ODataWCFService.GetProductDetails"
    parameters = odata_client_python.vector_odata_parameter()
    parameters.push_back(
        odata_client_python.odata_parameter(
            r"count",
            odata_client_python.odata_primitive_value.make_primitive_value(3)))
    returned_values = odata_client_python.vector_odata_value()
    client.send_data_to_server(product_details_path, parameters,
                               returned_values,
                               odata_client_python.HTTP_GET).get()
    print len(returned_values) == 3
    detail1 = odata_client_python.to_entity_value(returned_values[0])
    property_value = odata_client_python.odata_value()
    detail1.get_property_value(r"ProductID", property_value)
    primitive_value = odata_client_python.to_primitive_value(property_value)
    print eval(primitive_value.to_string()) == 5
def action_of_primitive_value():
    print r"==action_of_primitive_value=="
    client.send_data_to_server(r"ResetDataSource").get()
    company_revenue_path = r"Company/Revenue"
    revenue_odata_value = client.get_data_from_server(company_revenue_path).get()[0]
    revenue_primitive_value = odata_client_python.to_primitive_value(revenue_odata_value)
    revenue = eval(revenue_primitive_value.to_string())
    print revenue == 100000
    parameters = odata_client_python.vector_odata_parameter()
    parameters.push_back(odata_client_python.odata_parameter(r"IncreaseValue", odata_client_python.odata_primitive_value.make_primitive_value(100000)))
    returned_values = odata_client_python.vector_odata_value()
    client.send_data_to_server(r"Company/Microsoft.Test.OData.Services.ODataWCFService.IncreaseRevenue", parameters, returned_values).get()
    print len(returned_values) == 1
    returned_value = returned_values[0]
    revenue_odata_value = client.get_data_from_server(company_revenue_path).get()[0]
    revenue_primitive_value = odata_client_python.to_primitive_value(revenue_odata_value)
    revenue = eval(revenue_primitive_value.to_string())
    print revenue == 200000
    returned_primitive_value = odata_client_python.to_primitive_value(returned_value)
    print eval(returned_primitive_value.to_string()) == 200000
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"