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"
Esempio n. 2
0
 def operation_query_primitive(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
         primitive_value = odata_client_python.to_primitive_value(value)
         if primitive_value is None:
             continue
         try:
             if ret_type in ("uint8_t", "int8_t", "int16_t", "int32_t", "int64_t") or ret_type is int:
                 val = int(primitive_value.to_string())
             elif ret_type in ("float", "double", "long double") or ret_type is float:
                 val = float(primitive_value.to_string())
             elif ret_type == "bool" or ret_type is bool:
                 val = primitive_value.to_string() == "true"
             elif ret_type == "::utility::string_t" or ret_type is str or ret_type is unicode:
                 val = primitive_value.to_string()
             else:
                 val = eval(primitive_value.to_string())
         except:
             val = primitive_value.to_string()
         ret.append(val)
     return ret
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 simple_function():
    print r"==simple_function=="
    client.send_data_to_server(r"ResetDataSource").get()
    employees_count_path = r"Company/Microsoft.Test.OData.Services.ODataWCFService.GetEmployeesCount"
    parameters = odata_client_python.vector_odata_parameter()
    returned_values = odata_client_python.vector_odata_value()
    client.send_data_to_server(employees_count_path, parameters, returned_values, odata_client_python.HTTP_GET).get()
    print len(returned_values) == 1
    print eval(odata_client_python.to_primitive_value(returned_values[0]).to_string()) == 2
Esempio n. 5
0
 def operation_query_singleton(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 = None
     if len(ret_values) != 1:
         return None
     entity_value = odata_client_python.to_entity_value(ret_values[0])
     return ret_type.create_instance_from_entity(entity_value, self)
def simple_function():
    print r"==simple_function=="
    client.send_data_to_server(r"ResetDataSource").get()
    employees_count_path = r"Company/Microsoft.Test.OData.Services.ODataWCFService.GetEmployeesCount"
    parameters = odata_client_python.vector_odata_parameter()
    returned_values = odata_client_python.vector_odata_value()
    client.send_data_to_server(employees_count_path, parameters,
                               returned_values,
                               odata_client_python.HTTP_GET).get()
    print len(returned_values) == 1
    print eval(
        odata_client_python.to_primitive_value(
            returned_values[0]).to_string()) == 2
Esempio n. 7
0
 def operation_query_entityset(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
         entity_value = odata_client_python.to_entity_value(value)
         if entity_value is None:
             continue
         ret.append(ret_type.create_instance_from_entity(entity_value, self))
     return ret
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
Esempio n. 9
0
 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"
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_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"
Esempio n. 15
0
 def operation_query_void(self, query_ex, parameters, is_function):
     if self._client is None:
         return -1
     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()
     return 0