class MediaMapping(ProtoMapping): __proto__ = domain_pb2.UserMedia __source_input_type__ = sql.Media author = ProtoKey('author', UserMapping) download_url = ProtoKey('link', str) blob = ProtoKey('blob', bytes) content_type = ProtoKey('content_type', bytes)
class UserMapping(ProtoMapping): __proto__ = domain_pb2.User __source_input_type__ = sql.User uuid = ProtoKey('id', str) email = ProtoKey('email', str) username = ProtoKey('login', str) tokens = ProtoList('tokens', UserAuthTokenMapping) metadata = ProtoKey('extra_info', dict)
def test_field_mapping_cast_returns_doesnt_touch_value_target_type_none(): "FieldMapping.cast() returns the value untouched if the target type is None" key = ProtoKey('username') value = object() result = key.cast(value) result.should.equal(value)
class AuthResponseMapping(ProtoMapping): __proto__ = domain_pb2.AuthResponse token = ProtoKey('token', UserAuthTokenMapping)
class UserAuthTokenMapping(ProtoMapping): __proto__ = domain_pb2.User.AuthToken __source_input_type__ = sql.AuthToken value = ProtoKey('data', str) created_at = ProtoKey('created_at', ProtobufTimestamp) expires_at = ProtoKey('expires_at', ProtobufTimestamp)
class AuthRequestMapping(ProtoMapping): __proto__ = domain_pb2.AuthRequest username = ProtoKey('username', str) password = ProtoKey('password', str)
class TimestampMapping(ProtoMapping): __proto__ = Timestamp seconds = ProtoKey('seconds', int)
class TimestampMapping(ProtoMapping): __proto__ = Timestamp __source_input_type__ = MyCustomObjectWithTimestampData seconds = ProtoKey('seconds', int)