Exemplo n.º 1
0
 def test_binary_set_deserialize(self):
     """
     BinarySetAttribute.deserialize
     """
     attr = BinarySetAttribute()
     value = set([b"foo", b"bar"])
     self.assertEqual(attr.deserialize([b64encode(val).decode(DEFAULT_ENCODING) for val in sorted(value)]), value)
Exemplo n.º 2
0
 def test_binary_set_round_trip(self):
     """
     BinarySetAttribute round trip
     """
     attr = BinarySetAttribute()
     value = set([b'foo', b'bar'])
     serial = attr.serialize(value)
     self.assertEqual(attr.deserialize(serial), value)
Exemplo n.º 3
0
 def test_binary_set_deserialize(self):
     """
     BinarySetAttribute.deserialize
     """
     attr = BinarySetAttribute()
     value = set([b'foo', b'bar'])
     assert attr.deserialize(
         [b64encode(val).decode(DEFAULT_ENCODING) for val in sorted(value)]
     ) == value
Exemplo n.º 4
0
 def test_binary_set_deserialize(self):
     """
     BinarySetAttribute.deserialize
     """
     attr = BinarySetAttribute()
     value = set([b'foo', b'bar'])
     assert attr.deserialize(
         [b64encode(val).decode(DEFAULT_ENCODING) for val in sorted(value)]
     ) == value
Exemplo n.º 5
0
    def test_binary_set_attribute(self):
        """
        BinarySetAttribute.serialize
        """
        attr = BinarySetAttribute()
        assert attr is not None

        attr = BinarySetAttribute(default={b'foo', b'bar'})
        assert attr.default == {b'foo', b'bar'}
Exemplo n.º 6
0
 def test_binary_set_serialize(self):
     """
     BinarySetAttribute.serialize
     """
     attr = BinarySetAttribute()
     self.assertEqual(attr.attr_type, BINARY_SET)
     self.assertEqual(
         attr.serialize(set([b'foo', b'bar'])),
         [b64encode(val).decode(DEFAULT_ENCODING) for val in sorted(set([b'foo', b'bar']))])
     self.assertEqual(attr.serialize(None), None)
Exemplo n.º 7
0
 def test_binary_set_serialize(self):
     """
     BinarySetAttribute.serialize
     """
     attr = BinarySetAttribute()
     assert attr.attr_type == BINARY_SET
     assert attr.serialize(set([b'foo', b'bar'])) == [
         b64encode(val).decode(DEFAULT_ENCODING) for val in sorted(set([b'foo', b'bar']))
     ]
     assert attr.serialize(None) is None
Exemplo n.º 8
0
 def test_binary_set_serialize(self):
     """
     BinarySetAttribute.serialize
     """
     attr = BinarySetAttribute()
     assert attr.attr_type == BINARY_SET
     assert attr.serialize(set([b'foo', b'bar'])) == [
         b64encode(val).decode(DEFAULT_ENCODING) for val in sorted(set([b'foo', b'bar']))
     ]
     assert attr.serialize(None) is None
    class DataModel(Model):
        class Meta:
            table_name = 'binary_set_attr_update'
            host = ddb_url

        pkey = UnicodeAttribute(hash_key=True)
        data = BinarySetAttribute()
Exemplo n.º 10
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()
class MyDocument(BaseDocument, discriminator="my_document"):
    status = UnicodeEnumAttribute(MyStatus, default=MyStatus.CREATED)
    content = UnicodeAttribute()
    tokens = BinarySetAttribute()
    version = VersionAttribute(null=True)
    cls = DiscriminatorAttribute()
Exemplo n.º 12
0
def test_should_binary_set_convert_list():
    assert_attribute_conversion(BinarySetAttribute(), graphene.List)