コード例 #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)
        ]
コード例 #2
0
 class _RepoForkForm(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(), v.OneOf(repo_groups,
                                                 hideList=True))
     repo_type = All(v.ValidForkType(old_data), v.OneOf(supported_backends))
     description = v.UnicodeString(strip=True, min=1, not_empty=True)
     private = v.StringBoolean(if_missing=False)
     copy_permissions = v.StringBoolean(if_missing=False)
     fork_parent_id = v.UnicodeString()
     chained_validators = [v.ValidForkName(edit, old_data)]
     landing_rev = v.OneOf(landing_revs, hideList=True)
コード例 #3
0
    class _ReposGroupForm(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)
        if edit:
            #FIXME: do a special check that we cannot move a group to one of
            #it's children
            pass
        group_parent_id = All(
            v.CanCreateGroup(can_create_in_root),
            v.OneOf(available_groups,
                    hideList=False,
                    testValueList=True,
                    if_missing=None,
                    not_empty=True))
        enable_locking = v.StringBoolean(if_missing=False)
        chained_validators = [v.ValidReposGroup(edit, old_data)]
コード例 #4
0
    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))
コード例 #5
0
 def test_SlugifyName(self, name, expected):
     validator = v.SlugifyName()
     self.assertEqual(expected, validator.to_python(name))
コード例 #6
0
def test_SlugifyName(name, expected):
    validator = v.SlugifyName()
    assert expected == validator.to_python(name)