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)
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)
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
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
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'}
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)
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
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()
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()
def test_should_binary_set_convert_list(): assert_attribute_conversion(BinarySetAttribute(), graphene.List)