Exemple #1
0
    def _c_wrapper(self, value_array):
        value_type = type(value_array[0])
        if not all(isinstance(x, value_type) for x in value_array):
            raise ValueError("All Array values must be the same type.")

        c_array = c_uamqp.array_value()
        for value in value_array:
            c_array.append(utils.data_factory(value))
        return c_array
Exemple #2
0
def test_array_value():
    value = c_uamqp.array_value()
    assert value.type == c_uamqp.AMQPType.ArrayValue
    assert value.size == 0

    val_1 = c_uamqp.ubyte_value(122)
    val_2 = c_uamqp.ubyte_value(125)

    value.append(val_1)
    assert value[0].value == 122

    value.append(val_2)
    assert value[1].value == 125
    assert len(value) == 2
    
    with pytest.raises(IndexError):
        value[2]
    assert value.value == [122, 125]
    assert str(value) == "{122,125}"