Esempio n. 1
0
    def test_schema_path_b_is_current_user_miguel(self):
        schema_plain = {'b': {'type': str, 'get': current_user_is('user')}}
        B = Schema(schema_plain)

        schema_plain = {'a': {'type': B, 'set': public}, 'user': {'type': str}}

        A = Schema(schema_plain)

        with patch('schema.current_user') as mock:
            mock.return_value = 'miguel'
            value = A.get({'user': '******', 'a': {'b': 'hello'}})
            self.assertEqual(value, {'user': '******', 'a': {'b': 'hello'}})
Esempio n. 2
0
    def test_schema_path_set_object_array_invalid_current_user_is(self):
        schema_plain = {'b': {'type': str, 'set': public}}
        B = Schema(schema_plain)

        schema_plain = {
            '__set_document': public,
            '__set_default': never,
            'a': {
                'type': [B],
                'set': current_user_is('user')
            }
        }

        A = Schema(schema_plain)

        with patch('schema.current_user') as mock:
            mock.return_value = 'miguel'
            with self.assertRaises(SetError):
                A.put('a', {'user': '******'}, {'b': 'hello :)'})
Esempio n. 3
0
     "set": read_only
 },
 "title": {
     "type": str,
     "required": True,
     "validation": lambda v: 0 <= len(v) <= 30
 },
 "description": {
     "type": str,
     "required": True,
     "validation": lambda v: 0 <= len(v) <= 300
 },
 "status": {
     "type": str,
     "required": True,
     "set": current_user_is('offerer'),
     "validation": lambda v: v in ['open', 'discarded']
 },
 "tags": {
     "type": list
 },
 "candidate": {
     "type": str,
     "initial": current_user
 },
 "mark": {
     "type": Number
 },
 "offerer": {
     "type": str,
     "required": True,