コード例 #1
0
def test_extensible_record():
    ci = FooClientInterface.create()

    number1 = 10
    number2 = 1
    string1 = "hello"
    string2 = "does not matter"
    set_rec = FooExtensibleRecord(number1, string1)
    set_rec.number2 = number2  # to confirm it does not matter we are sending extended rather than base record
    set_rec.string2 = string2  # to confirm it does not matter we are sending extended rather than base record

    ci.set_extensible_record(set_rec)
    got_rec = ci.get_extensible_record()

    assert ci.get_extensible_record_number2(
    ) == number1 * 2, "test_extensible_record failed"
    assert ci.get_extensible_record_string2(
    ) == string1 + string1, "test_extensible_record failed"

    assert set_rec.number1 == got_rec.number1 and\
            set_rec.string1 == got_rec.string1 and\
            set_rec.number2 == number2 and \
            set_rec.string2 == string2, "test_extensible_record failed"

    # Check that we can call method specific to extended record
    assert isinstance(set_rec, FooExtensibleRecord)
    assert isinstance(got_rec, FooExtensibleRecord)
    assert set_rec.ret5() == 5, "test_extensible_record failed"
    assert got_rec.ret5() == 5, "test_extensible_record failed"
コード例 #2
0
ファイル: test_client_interface.py プロジェクト: trafi/djinni
def test_extensible_record():
    ci = FooClientInterface.create()

    number1 = 10
    number2 = 1
    string1 = "hello"
    string2 = "does not matter"
    set_rec = FooExtensibleRecord(number1, string1)
    set_rec.number2 = number2                    # to confirm it does not matter we are sending extended rather than base record
    set_rec.string2 = string2    # to confirm it does not matter we are sending extended rather than base record

    ci.set_extensible_record(set_rec)
    got_rec = ci.get_extensible_record()

    assert ci.get_extensible_record_number2() == number1 * 2, "test_extensible_record failed"
    assert ci.get_extensible_record_string2() == string1 + string1, "test_extensible_record failed"

    assert set_rec.number1 == got_rec.number1 and\
            set_rec.string1 == got_rec.string1 and\
            set_rec.number2 == number2 and \
            set_rec.string2 == string2, "test_extensible_record failed"

    # Check that we can call method specific to extended record
    assert isinstance(set_rec, FooExtensibleRecord)
    assert isinstance(got_rec, FooExtensibleRecord)
    assert set_rec.ret5() == 5, "test_extensible_record failed"
    assert got_rec.ret5() == 5, "test_extensible_record failed"
コード例 #3
0
def test_client_returned_record():
    ci = FooClientInterface.create()

    number1 = 10
    number2 = -10
    some_record = FooSomeOtherRecord(number1, number2)

    record_id = 28
    content = "Hello World"
    set_rec = FooClientReturnedRecord(record_id, content, some_record)

    ci.set_record(set_rec)
    get_rec = ci.get_record()

    assert set_rec.record_id == record_id and \
           set_rec.content == content and \
           set_rec.some_record.__dict__ == some_record.__dict__

    print("Forcing garbage collection in test_client_interface_py")
    set_rec = None
    get_rec = None
    some_record = None
    gc.collect()

    FooClientReturnedRecord.check_c_data_set_empty()
    FooSomeOtherRecord.check_c_data_set_empty()
コード例 #4
0
ファイル: test_client_interface.py プロジェクト: trafi/djinni
def test_client_returned_record():
    ci = FooClientInterface.create()

    number1 = 10
    number2 = -10
    some_record = FooSomeOtherRecord(number1, number2)

    record_id = 28
    content = "Hello World"
    set_rec = FooClientReturnedRecord(record_id, content, some_record)

    ci.set_record(set_rec)
    get_rec = ci.get_record()

    assert set_rec.record_id == record_id and \
           set_rec.content == content and \
           set_rec.some_record.__dict__ == some_record.__dict__

    print ("Forcing garbage collection in test_client_interface_py")
    set_rec = None
    get_rec = None
    some_record = None
    gc.collect()

    FooClientReturnedRecord.check_c_data_set_empty()
    FooSomeOtherRecord.check_c_data_set_empty()