Ejemplo n.º 1
0
 def test_delete_action(self):
     action = NumberSetAttribute(attr_name='foo').delete({'NS': ['0']})
     placeholder_names, expression_attribute_values = {}, {}
     expression = action.serialize(placeholder_names, expression_attribute_values)
     assert expression == "#0 :0"
     assert placeholder_names == {'foo': '#0'}
     assert expression_attribute_values == {':0': {'NS': ['0']}}
Ejemplo n.º 2
0
 def test_contains_number_set(self):
     condition = NumberSetAttribute(attr_name='foo').contains(1)
     placeholder_names, expression_attribute_values = {}, {}
     expression = condition.serialize(placeholder_names, expression_attribute_values)
     assert expression == "contains (#0, :0)"
     assert placeholder_names == {'foo': '#0'}
     assert expression_attribute_values == {':0': {'N' : '1'}}
Ejemplo n.º 3
0
 def test_number_set_serialize(self):
     """
     NumberSetAttribute.serialize
     """
     attr = NumberSetAttribute()
     assert attr.serialize(set(
         [1, 2])) == [json.dumps(val) for val in sorted(set([1, 2]))]
     assert attr.serialize(None) is None
Ejemplo n.º 4
0
 def test_number_set_deserialize(self):
     """
     NumberSetAttribute.deserialize
     """
     attr = NumberSetAttribute()
     assert attr.attr_type == NUMBER_SET
     assert attr.deserialize(
         [json.dumps(val) for val in sorted(set([1, 2]))]) == set([1, 2])
Ejemplo n.º 5
0
    def test_number_set_attribute(self):
        """
        NumberSetAttribute.default
        """
        attr = NumberSetAttribute()
        assert attr is not None

        attr = NumberSetAttribute(default=set([1, 2]))
        assert attr.default == set([1, 2])
Ejemplo n.º 6
0
class AttributeTestModel(Model):
    class Meta:
        host = 'http://localhost:8000'
        table_name = 'test'

    binary_attr = BinaryAttribute()
    binary_set_attr = BinarySetAttribute()
    number_attr = NumberAttribute()
    number_set_attr = NumberSetAttribute()
    unicode_attr = UnicodeAttribute()
    unicode_set_attr = UnicodeSetAttribute()
    datetime_attr = UTCDateTimeAttribute()
    bool_attr = BooleanAttribute()
    json_attr = JSONAttribute()
    map_attr = MapAttribute()