Beispiel #1
0
    class _RepoForm(formencode.Schema):
        allow_extra_fields = True
        filter_extra_fields = False
        repo_name = All(v.UnicodeString(strip=True, min=1, not_empty=True),
                        v.SlugifyName())
        repo_group = All(v.CanWriteGroup(old_data),
                         v.OneOf(repo_groups, hideList=True))
        repo_type = v.OneOf(supported_backends,
                            required=False,
                            if_missing=old_data.get('repo_type'))
        repo_description = v.UnicodeString(strip=True, min=1, not_empty=False)
        repo_private = v.StringBoolean(if_missing=False)
        repo_landing_rev = v.OneOf(landing_revs, hideList=True)
        clone_uri = All(v.UnicodeString(strip=True, min=1, not_empty=False))

        repo_enable_statistics = v.StringBoolean(if_missing=False)
        repo_enable_downloads = v.StringBoolean(if_missing=False)
        repo_enable_locking = v.StringBoolean(if_missing=False)

        if edit:
            #this is repo owner
            user = All(v.UnicodeString(not_empty=True), v.ValidRepoUser())

        chained_validators = [
            v.ValidCloneUri(),
            v.ValidRepoName(edit, old_data)
        ]
    class _UserGroupForm(formencode.Schema):
        allow_extra_fields = True
        filter_extra_fields = True

        users_group_name = All(
            v.UnicodeString(strip=True, min=1, not_empty=True),
            v.ValidUserGroup(edit, old_data))
        user_group_description = v.UnicodeString(strip=True,
                                                 min=1,
                                                 not_empty=False)

        users_group_active = v.StringBoolean(if_missing=False)

        if edit:
            users_group_members = v.OneOf(available_members,
                                          hideList=False,
                                          testValueList=True,
                                          if_missing=None,
                                          not_empty=False)
            # this is user group owner
            user = All(v.UnicodeString(not_empty=True),
                       v.ValidRepoUser(allow_disabled))
    class _RepoGroupForm(formencode.Schema):
        allow_extra_fields = True
        filter_extra_fields = False

        group_name = All(
            v.UnicodeString(strip=True, min=1, not_empty=True),
            v.SlugifyName(),
        )
        group_description = v.UnicodeString(strip=True, min=1, not_empty=False)
        group_copy_permissions = v.StringBoolean(if_missing=False)

        group_parent_id = v.OneOf(available_groups,
                                  hideList=False,
                                  testValueList=True,
                                  not_empty=True)
        enable_locking = v.StringBoolean(if_missing=False)
        chained_validators = [
            v.ValidRepoGroup(edit, old_data, can_create_in_root)
        ]

        if edit:
            # this is repo group owner
            user = All(v.UnicodeString(not_empty=True),
                       v.ValidRepoUser(allow_disabled))
Beispiel #4
0
 def test_ValidRepoUser(self):
     validator = v.ValidRepoUser()
     self.assertRaises(formencode.Invalid, validator.to_python, 'nouser')
     self.assertEqual(TEST_USER_ADMIN_LOGIN,
                      validator.to_python(TEST_USER_ADMIN_LOGIN))
def test_ValidRepoUser():
    validator = v.ValidRepoUser()
    pytest.raises(formencode.Invalid, validator.to_python, 'nouser')
    assert TEST_USER_ADMIN_LOGIN == \
        validator.to_python(TEST_USER_ADMIN_LOGIN)