예제 #1
0
    class User(Document):
        class Options(object):
            roles_to_propagate = not_(PARTIAL_RESPONSE_ROLE)

        with Scope(DB_ROLE) as db:
            db._id = StringField(required=True)
            db.version = StringField(required=True)
        with Scope(lambda r: r.startswith(RESPONSE_ROLE) or r == REQUEST_ROLE) as response:
            response.id = StringField(required=when_not(PARTIAL_RESPONSE_ROLE))
        with Scope(not_(REQUEST_ROLE)) as not_request:
            not_request.messages = ArrayField(DocumentField(Message), required=when_not(PARTIAL_RESPONSE_ROLE))
예제 #2
0
파일: test_roles.py 프로젝트: sseg/jsl
def test_scope():
    scope = Scope(DB_ROLE)
    f = StringField()
    scope.login = f
    assert scope.login == f

    assert scope.__fields__ == {
        'login': f,
    }

    with pytest.raises(AttributeError):
        scope.gsomgsom
예제 #3
0
def test_scope():
    scope = Scope(DB_ROLE)
    f = StringField()
    scope.login = f
    assert scope.login == f

    assert scope.__fields__ == {
        'login': f,
    }

    with pytest.raises(AttributeError):
        scope.gsomgsom
예제 #4
0
파일: test_roles.py 프로젝트: sseg/jsl
 class Message(Document):
     with Scope(DB_ROLE) as db:
         db.uuid = StringField(required=True)
     created_at = IntField(
         required=when_not(PARTIAL_RESPONSE_ROLE, REQUEST_ROLE))
     text = StringField(required=when_not(PARTIAL_RESPONSE_ROLE))
     field_that_is_never_present = Var(
         {'NEVER': StringField(required=True)})
예제 #5
0
 class X(Document):
     with Scope('role_1') as s_1:
         s_1.name = StringField()
     with Scope('role_2') as s_2:
         s_2.name = StringField()
예제 #6
0
    class Test(Document):
        class Options(object):
            definition_id = 'test'

        with Scope('test') as test:
            test.field = DocumentField(RECURSIVE_REFERENCE_CONSTANT)
예제 #7
0
파일: test_roles.py 프로젝트: keith923/jsl
 class Message(Document):
     with Scope(DB_ROLE) as db:
         db.uuid = StringField(required=True)
     created_at = IntField(
         required=when_not(PARTIAL_RESPONSE_ROLE, REQUEST_ROLE))
     text = StringField(required=when_not(PARTIAL_RESPONSE_ROLE))