当前位置: 首页>>代码示例>>Python>>正文


Python utils.randstring函数代码示例

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


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


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