def create_entity():
    print r"==create_entity=="
    client.send_data_to_server(r"ResetDataSource").get()
    model = client.get_model().get()
    entity_set_name = r"Accounts"
    entity = odata_client_python.odata_entity_value(
        model.find_container().find_entity_set(
            entity_set_name).get_entity_type())
    entity.set_value(r"AccountID", 130)
    entity.set_value(r"CountryRegion", "CN")
    account_info = odata_client_python.odata_complex_value(
        model.find_complex_type(r"AccountInfo"))
    account_firstname = r"cpp"
    account_lastname = r"client"
    account_info.set_value(r"FirstName", account_firstname)
    account_info.set_value(r"LastName", account_lastname)
    entity.set_value(r"AccountInfo", account_info)
    response_code = client.create_entity(entity_set_name, entity).get()
    print response_code == 201
    query_result = client.get_data_from_server(r"Accounts(130)").get()
    print len(query_result) == 1
    new_entity = odata_client_python.to_entity_value(query_result[0])
    property_value = odata_client_python.odata_value()
    print entity.get_property_value(r"AccountID", property_value)
    primitive_value = odata_client_python.to_primitive_value(property_value)
    new_id = eval(primitive_value.to_string())
    print new_id == 130
Ejemplo n.º 2
0
def create_contained_entity():
    print r"==create_contained_entity=="
    client.send_data_to_server(r"ResetDataSource").get()
    model = client.get_model().get()
    entity_type_name = r"PaymentInstrument"
    entity = odata_client_python.odata_entity_value(model.find_entity_type(entity_type_name))
    entity.set_value(r"PaymentInstrumentID", 101920)
    entity.set_value(r"FriendlyName", r"created by cpp test")
    now = odata_client_python.datetime.utc_now()
    entity.set_value(r"CreatedDate", now)
    response_code = client.create_entity(r"Accounts(101)/MyPaymentInstruments", entity).get()
    print response_code == 201
    query_result = client.get_data_from_server(r"Accounts(101)/MyPaymentInstruments(101920)").get()
    print len(query_result) == 1
    new_entity = odata_client_python.to_entity_value(query_result[0])
    property_value = odata_client_python.odata_value()
    print entity.get_property_value(r"FriendlyName", property_value)
    primitive_value = odata_client_python.to_primitive_value(property_value)
    print primitive_value.to_string() == r"created by cpp test"
Ejemplo n.º 3
0
def create_contained_single_valued_entity():
    print r"==create_contained_single_valued_entity=="
    client.send_data_to_server(r"ResetDataSource").get()
    model = client.get_model().get()
    entity_type_name = r"GiftCard"
    entity = odata_client_python.odata_entity_value(model.find_entity_type(entity_type_name))
    entity.set_value(r"GiftCardID", 304)
    card_number = r"AAASSSDD30"
    entity.set_value(r"GiftCardNO", card_number)
    entity.set_value(r"Amount", 132.0)
    now = odata_client_python.datetime.utc_now()
    entity.set_value(r"ExperationDate", now)
    response_code = client.send_data_to_server(r"Accounts(104)/MyGiftCard", entity, r"PATCH").get()
    print response_code == 204
    query_result = client.get_data_from_server(r"Accounts(104)/MyGiftCard").get()
    print len(query_result) == 1
    new_entity = odata_client_python.to_entity_value(query_result[0])
    property_value = odata_client_python.odata_value()
    print entity.get_property_value(r"Amount", property_value)
    primitive_value = odata_client_python.to_primitive_value(property_value)
    print eval(primitive_value.to_string()) == 132.0
def create_contained_entity():
    print r"==create_contained_entity=="
    client.send_data_to_server(r"ResetDataSource").get()
    model = client.get_model().get()
    entity_type_name = r"PaymentInstrument"
    entity = odata_client_python.odata_entity_value(
        model.find_entity_type(entity_type_name))
    entity.set_value(r"PaymentInstrumentID", 101920)
    entity.set_value(r"FriendlyName", r"created by cpp test")
    now = odata_client_python.datetime.utc_now()
    entity.set_value(r"CreatedDate", now)
    response_code = client.create_entity(r"Accounts(101)/MyPaymentInstruments",
                                         entity).get()
    print response_code == 201
    query_result = client.get_data_from_server(
        r"Accounts(101)/MyPaymentInstruments(101920)").get()
    print len(query_result) == 1
    new_entity = odata_client_python.to_entity_value(query_result[0])
    property_value = odata_client_python.odata_value()
    print entity.get_property_value(r"FriendlyName", property_value)
    primitive_value = odata_client_python.to_primitive_value(property_value)
    print primitive_value.to_string() == r"created by cpp test"
Ejemplo n.º 5
0
def create_entity():
    print r"==create_entity=="
    client.send_data_to_server(r"ResetDataSource").get()
    model = client.get_model().get()
    entity_set_name = r"Accounts"
    entity = odata_client_python.odata_entity_value(model.find_container().find_entity_set(entity_set_name).get_entity_type())
    entity.set_value(r"AccountID", 130)
    entity.set_value(r"CountryRegion", "CN")
    account_info = odata_client_python.odata_complex_value(model.find_complex_type(r"AccountInfo"))
    account_firstname = r"cpp"
    account_lastname = r"client"
    account_info.set_value(r"FirstName", account_firstname)
    account_info.set_value(r"LastName", account_lastname)
    entity.set_value(r"AccountInfo", account_info)
    response_code = client.create_entity(entity_set_name, entity).get()
    print response_code == 201
    query_result = client.get_data_from_server(r"Accounts(130)").get()
    print len(query_result) == 1
    new_entity = odata_client_python.to_entity_value(query_result[0])
    property_value = odata_client_python.odata_value()
    print entity.get_property_value(r"AccountID", property_value)
    primitive_value = odata_client_python.to_primitive_value(property_value)
    new_id = eval(primitive_value.to_string())
    print new_id == 130
def create_contained_single_valued_entity():
    print r"==create_contained_single_valued_entity=="
    client.send_data_to_server(r"ResetDataSource").get()
    model = client.get_model().get()
    entity_type_name = r"GiftCard"
    entity = odata_client_python.odata_entity_value(
        model.find_entity_type(entity_type_name))
    entity.set_value(r"GiftCardID", 304)
    card_number = r"AAASSSDD30"
    entity.set_value(r"GiftCardNO", card_number)
    entity.set_value(r"Amount", 132.0)
    now = odata_client_python.datetime.utc_now()
    entity.set_value(r"ExperationDate", now)
    response_code = client.send_data_to_server(r"Accounts(104)/MyGiftCard",
                                               entity, r"PATCH").get()
    print response_code == 204
    query_result = client.get_data_from_server(
        r"Accounts(104)/MyGiftCard").get()
    print len(query_result) == 1
    new_entity = odata_client_python.to_entity_value(query_result[0])
    property_value = odata_client_python.odata_value()
    print entity.get_property_value(r"Amount", property_value)
    primitive_value = odata_client_python.to_primitive_value(property_value)
    print eval(primitive_value.to_string()) == 132.0