• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utils.randstring函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tests.common.utils.randstring函数的典型用法代码示例。如果您正苦于以下问题:Python randstring函数的具体用法?Python randstring怎么用?Python randstring使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了randstring函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: setUp

    def setUp(self):

        self.login_as(self.admin)

        # create group for admin user
        self.admin_group_1_name = randstring(6)
        self.admin_group_1_id = ccnet_threaded_rpc.create_group(self.admin_group_1_name,
                self.admin.email)

        # create another group for admin user
        self.admin_group_2_name = randstring(6)
        self.admin_group_2_id = ccnet_threaded_rpc.create_group(self.admin_group_2_name,
                self.admin.email)

        # create repo for admin user
        self.admin_repo_name = randstring(6)
        r = seafile_api.get_repo(self.create_repo(name=self.admin_repo_name,
            desc='', username=self.admin.email, passwd=None))
        self.admin_repo_id = r.id

        # set common user as staff in admin user's group
        ccnet_threaded_rpc.group_add_member(self.admin_group_1_id,
                self.admin.email, self.user.email)
        ccnet_threaded_rpc.group_set_admin(self.admin_group_1_id, self.user.email)

        # add common user to admin user's another group
        ccnet_threaded_rpc.group_add_member(self.admin_group_2_id,
                self.admin.email, self.user.email)

        # share admin user's repo to common user
        seafile_api.share_repo(self.admin_repo_id, self.admin.email,
                               self.user.email, 'rw')
开发者ID:ERamseth,项目名称:seahub,代码行数:32,代码来源:test_sysadmin.py


示例2: test_invalid_user

    def test_invalid_user(self):
        self.login_as(self.user)

        invalid_user = randstring(6) + '@' + randstring(6) + '.com'

        # test add
        url = reverse("api2-repo-user-folder-perm", args=[self.user_repo_id])
        data = {
            "user": invalid_user,
            "path": self.user_folder_path,
            "perm": self.perm_rw
        }
        resp = self.client.post(url, data)
        self.assertEqual(404, resp.status_code)

        # test modify
        url = reverse("api2-repo-user-folder-perm", args=[self.user_repo_id])
        data = 'user=%s&path=%s&perm=%s' % (invalid_user, self.user_folder_path, self.perm_rw)
        resp = self.client.put(url, data, 'application/x-www-form-urlencoded')
        self.assertEqual(404, resp.status_code)

        # test delete
        url = reverse("api2-repo-user-folder-perm", args=[self.user_repo_id])
        data = 'user=%s&path=%s' % (invalid_user, self.user_folder_path)
        resp = self.client.delete(url, data, 'application/x-www-form-urlencoded')
        self.assertEqual(404, resp.status_code)
开发者ID:rabb1t,项目名称:seahub,代码行数:26,代码来源:test_repo_user_folder_perm.py


示例3: test_create_in_encrypted_lib_with_invalid_password

    def test_create_in_encrypted_lib_with_invalid_password(self):

        password = randstring(8)
        encrypted_repo_id = seafile_api.create_repo(
                'encrypted_repo_name', '', self.user_name, password)

        dirname = randstring(8)
        seafile_api.post_dir(repo_id=encrypted_repo_id,
                parent_dir='/', dirname=dirname, username=self.user_name)

        self.login_as(self.user)

        url = reverse("api2-dir-sub-repo", args=[encrypted_repo_id])

        # test invalid password argument
        args = "?p=/%s&name=%s&invalid_password=%s" % (dirname, dirname, password)
        resp = self.client.get(url + args)
        self.assertEqual(400, resp.status_code)

        # test wrong password
        args = "?p=/%s&name=%s&password=%s" % (dirname, dirname, 'invalid_password')
        resp = self.client.get(url + args)
        self.assertEqual(400, resp.status_code)
        json_resp = json.loads(resp.content)
        assert json_resp['error_msg'] == 'Wrong password'

        self.remove_repo(encrypted_repo_id)
开发者ID:RaphaelWimmer,项目名称:seahub,代码行数:27,代码来源:test_dir_sub_repo.py


示例4: test_rename_file_with_invalid_folder_perm

    def test_rename_file_with_invalid_folder_perm(self):

        if not LOCAL_PRO_DEV_ENV:
            return

        # create a file as old file in user repo sub-folder
        old_file_name = randstring(6)
        seafile_api.post_empty_file(repo_id=self.repo_id,
                parent_dir=self.folder_path, filename=old_file_name,
                username=self.user_name)

        # share user's repo to admin with 'rw' permission
        seafile_api.share_repo(self.repo_id, self.user_name,
                self.admin_name, 'rw')

        # set sub-folder permisson as 'r' for admin
        seafile_api.add_folder_user_perm(self.repo_id,
                self.folder_path, 'r', self.admin_name)

        # admin can visit old file with 'r' permission
        old_file_path = posixpath.join(self.folder_path, old_file_name)
        assert seafile_api.check_permission_by_path(self.repo_id,
                old_file_path, self.admin_name) == 'r'

        # login as admin, then rename a 'r' permission old file
        self.login_as(self.admin)

        new_name = randstring(6)
        data = {'operation': 'rename', 'newname': new_name}

        resp = self.client.post(self.url + '?p=' + old_file_path, data)
        self.assertEqual(403, resp.status_code)
开发者ID:RaphaelWimmer,项目名称:seahub,代码行数:32,代码来源:test_file_view.py


示例5: test_invalid_perm

    def test_invalid_perm(self):
        self.login_as(self.user)

        invalid_perm = randstring(1)
        while invalid_perm == 'r':
            invalid_perm = randstring(1)

        # test add
        url = reverse("api2-repo-user-folder-perm", args=[self.user_repo_id])
        data = {
            "user": self.admin_email,
            "path": self.user_folder_path,
            "perm": invalid_perm
        }
        resp = self.client.post(url, data)
        self.assertEqual(400, resp.status_code)

        invalid_perm = randstring(2)
        while invalid_perm == 'rw':
            invalid_perm = randstring(2)

        # test modify
        url = reverse("api2-repo-user-folder-perm", args=[self.user_repo_id])
        data = 'user=%s&path=%s&perm=%s' % (self.admin_email, self.user_folder_path, invalid_perm)
        resp = self.client.put(url, data, 'application/x-www-form-urlencoded')
        self.assertEqual(400, resp.status_code)
开发者ID:rabb1t,项目名称:seahub,代码行数:26,代码来源:test_repo_user_folder_perm.py


示例6: test_can_not_transfer_repo_to_unregistered_user

    def test_can_not_transfer_repo_to_unregistered_user(self):
        self.login_as(self.user)

        url = reverse("api2-repo-owner", args=[self.user_repo_id])
        unregistered_user = '%[email protected]%s.com' % (randstring(6), randstring(6))
        data = 'owner=%s' % unregistered_user

        resp = self.client.put(url, data, 'application/x-www-form-urlencoded')
        self.assertEqual(404, resp.status_code)
开发者ID:AviorAlong,项目名称:haiwen-5.1.3,代码行数:9,代码来源:test_repo_owner.py


示例7: setUp

    def setUp(self):
        self.user_email = self.user.username
        self.admin_email = self.admin.username

        tmp_admin_email = '%[email protected]%s.com' % (randstring(6), randstring(6))
        ccnet_api.add_emailuser(tmp_admin_email, randstring(6), 1, 1)
        self.tmp_admin_email = tmp_admin_email

        AdminRole.objects.all().delete()
开发者ID:haiwen,项目名称:seahub,代码行数:9,代码来源:test_admin_role.py


示例8: test_unshare_repo_with_unregistered_user

    def test_unshare_repo_with_unregistered_user(self):
        self._add_shared_items()
        self.login_as(self.user)

        unregistered_user = '%[email protected]%s.com' % (randstring(6), randstring(6))

        resp = self.client.delete('/api2/repos/%s/dir/shared_items/?p=%s&share_type=user&username=%s' % (
            self.repo.id,
            self.folder,
            unregistered_user
        ))
        self.assertEqual(200, resp.status_code)
开发者ID:TanLian,项目名称:seahub,代码行数:12,代码来源:test_dir_shared_items.py


示例9: test_add_remove_group_with_blank_and_hyphen

    def test_add_remove_group_with_blank_and_hyphen(self):
        data = {'group_name': randstring(4) + '-' + randstring(4) + ' ' + randstring(4)}
        info = self.put(GROUPS_URL, data=data).json()
        self.assertTrue(info['success'])
        group_id = info['group_id']
        self.assertGreater(group_id, 0)
        url = urljoin(GROUPS_URL, str(group_id))
        self.delete(url)

        # check group is really removed
        groups = self.get(GROUPS_URL).json()['groups']
        for group in groups:
            self.assertNotEqual(group['id'], group_id)
开发者ID:AviorAlong,项目名称:haiwen-5.1.3,代码行数:13,代码来源:test_groups.py


示例10: test_modify_shared_repo_with_unregistered_user

    def test_modify_shared_repo_with_unregistered_user(self):
        self._add_shared_items()
        self.login_as(self.user)

        unregistered_user = '%[email protected]%s.com' % (randstring(6), randstring(6))

        resp = self.client.post('/api2/repos/%s/dir/shared_items/?p=%s&share_type=user&username=%s' % (
            self.repo.id,
            self.folder,
            unregistered_user), {
                'permission': 'r'
            }
        )
        self.assertEqual(400, resp.status_code)
开发者ID:TanLian,项目名称:seahub,代码行数:14,代码来源:test_dir_shared_items.py


示例11: test_share_folder_to_unregistered_user

    def test_share_folder_to_unregistered_user(self):
        self.login_as(self.user)
        unregistered_user = '%[email protected]%s.com' % (randstring(6), randstring(6))

        resp = self.client.put(
            '/api2/repos/%s/dir/shared_items/?p=%s' % (self.repo.id,
                                                       self.folder),
            "share_type=user&username=%s" % unregistered_user,
            'application/x-www-form-urlencoded',
        )
        self.assertEqual(200, resp.status_code)
        json_resp = json.loads(resp.content)
        assert len(json_resp['failed']) == 1
        assert unregistered_user in json_resp['failed'][0]['email']
开发者ID:TanLian,项目名称:seahub,代码行数:14,代码来源:test_dir_shared_items.py


示例12: test_can_add_with_blank_and_hyphen

 def test_can_add_with_blank_and_hyphen(self):
     resp = self.client.post(
         reverse("group_add"),
         {"group_name": "test-group %s" % randstring(6)},
         HTTP_X_REQUESTED_WITH="XMLHttpRequest",
     )
     assert json.loads(resp.content)["success"] is True
开发者ID:pombredanne,项目名称:seahub,代码行数:7,代码来源:test_group.py


示例13: test_rename_folder_with_invalid_folder_perm

    def test_rename_folder_with_invalid_folder_perm(self):

        if not LOCAL_PRO_DEV_ENV:
            return

        # share user's repo to admin with 'rw' permission
        seafile_api.share_repo(self.repo_id, self.user_name,
                self.admin_name, 'rw')

        # set sub-folder permisson as 'r' for admin
        seafile_api.add_folder_user_perm(self.repo_id,
                self.folder_path, 'r', self.admin_name)

        # admin can visit sub-folder with 'r' permission
        assert seafile_api.check_permission_by_path(self.repo_id,
                self.folder_path, self.admin_name) == 'r'

        # login as admin, then rename a 'r' permission folder
        self.login_as(self.admin)

        new_name = randstring(6)
        data = {'operation': 'rename', 'newname': new_name}

        resp = self.client.post(self.url + '?p=' + self.folder_path, data)
        self.assertEqual(403, resp.status_code)
开发者ID:RaphaelWimmer,项目名称:seahub,代码行数:25,代码来源:test_dir_view.py


示例14: setUp

    def setUp(self):
        self.tmp_user = self.create_user('user_%[email protected]' % randstring(4),
                                         is_staff=False)
        assert len(Profile.objects.all()) == 0

        self.url = reverse('edit_profile')
        self.login_as(self.tmp_user)
开发者ID:AviorAlong,项目名称:haiwen-5.1.3,代码行数:7,代码来源:test_edit_profile.py


示例15: test_delete_file_with_invalid_folder_perm

    def test_delete_file_with_invalid_folder_perm(self):

        if not LOCAL_PRO_DEV_ENV:
            return

        # create a file in user repo sub-folder
        file_name = randstring(6)
        seafile_api.post_empty_file(repo_id=self.repo_id,
                parent_dir=self.folder_path, filename=file_name,
                username=self.user_name)

        # share user's repo to admin with 'rw' permission
        seafile_api.share_repo(self.repo_id, self.user_name,
                self.admin_name, 'rw')

        # set sub-folder permisson as 'r' for admin
        seafile_api.add_folder_user_perm(self.repo_id,
                self.folder_path, 'r', self.admin_name)

        # admin can visit file with 'r' permission
        file_path = posixpath.join(self.folder_path, file_name)
        assert seafile_api.check_permission_by_path(self.repo_id,
                file_path, self.admin_name) == 'r'

        # login as admin, then delete a 'r' permission file
        self.login_as(self.admin)

        resp = self.client.delete(self.url + '?p=' + file_path,
                {}, 'application/x-www-form-urlencoded')
        self.assertEqual(403, resp.status_code)
开发者ID:RaphaelWimmer,项目名称:seahub,代码行数:30,代码来源:test_file_view.py


示例16: create_file

 def create_file(self, repo, fname=None):
     fname = fname or ("文件 %s.txt" % randstring())
     furl = repo.get_filepath_url("/" + fname)
     data = {"operation": "create"}
     res = self.post(furl, data=data, expected=201)
     self.assertEqual(res.text, '"success"')
     return fname, furl
开发者ID:skmezanul,项目名称:seahub,代码行数:7,代码来源:apitestbase.py


示例17: test_invalid_path

    def test_invalid_path(self):
        self.login_as(self.user)

        invalid_path = randstring(6)

        # test delete
        url = reverse("api2-repo-group-folder-perm", args=[self.user_repo_id])
        data = 'group_id=%s&folder_path=%s' % (self.group_id, invalid_path)
        resp = self.client.delete(url, data, 'application/x-www-form-urlencoded')
        self.assertEqual(404, resp.status_code)

        # test modify
        url = reverse("api2-repo-group-folder-perm", args=[self.user_repo_id])
        data = 'group_id=%s&folder_path=%s&permission=%s' % (self.group_id, invalid_path, self.perm_rw)
        resp = self.client.put(url, data, 'application/x-www-form-urlencoded')
        self.assertEqual(404, resp.status_code)

        # test add
        url = reverse("api2-repo-group-folder-perm", args=[self.user_repo_id])
        data = {
            "group_id": self.group_id,
            "folder_path": invalid_path,
            "permission": self.perm_rw
        }
        resp = self.client.post(url, data)
        self.assertEqual(404, resp.status_code)
开发者ID:AviorAlong,项目名称:haiwen-5.1.3,代码行数:26,代码来源:test_repo_group_folder_perm.py


示例18: create_dir

 def create_dir(self, repo):
     data = {'operation': 'mkdir'}
     dpath = '/目录 %s' % randstring()
     durl = repo.get_dirpath_url(dpath)
     res = self.post(durl, data=data, expected=201)
     self.assertEqual(res.text, u'"success"')
     return dpath, durl
开发者ID:DionysosLai,项目名称:seahub,代码行数:7,代码来源:apitestbase.py


示例19: test_create_encrypted_repo

    def test_create_encrypted_repo(self):
        """Test create an encrypted repo with the secure keys generated on client
        side.
        """
        repo_id = str(uuid.uuid4())
        password = randstring(16)
        enc_version = 2
        enc_info = seafile_api.generate_magic_and_random_key(enc_version, repo_id, password)
        data = {
            'name': 'enc-test',
            'repo_id': repo_id,
            'enc_version': enc_version,
            'magic': enc_info.magic,
            'random_key': enc_info.random_key,
        }
        res = self.post(REPOS_URL, data=data)
        repo = res.json()
        assert repo['repo_id'] == repo_id
        assert repo['encrypted']
        assert repo['magic'] == enc_info.magic
        assert repo['random_key'] == enc_info.random_key

        # validate the password on server
        set_password_url = apiurl('/api2/repos/{}/'.format(repo['repo_id']))
        self.post(set_password_url, data={'password': password})

        # do some file operation
        self.create_file(repo['repo_id'])
开发者ID:AviorAlong,项目名称:haiwen-5.1.3,代码行数:28,代码来源:test_repos.py


示例20: _add_file_shared_link_with_password

    def _add_file_shared_link_with_password(self):
        password = randstring(6)
        uls = FileShare.objects.create_file_link(self.user.username,
                                                 self.repo.id, self.file,
                                                 password)

        return (uls.token, password)
开发者ID:AviorAlong,项目名称:haiwen-5.1.3,代码行数:7,代码来源:test_shares.py



注:本文中的tests.common.utils.randstring函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.urljoin函数代码示例发布时间:2022-05-27
下一篇:
Python utils.raises函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap