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


Python CodeDoubanProject.add方法代码示例

本文整理汇总了Python中vilya.models.project.CodeDoubanProject.add方法的典型用法代码示例。如果您正苦于以下问题:Python CodeDoubanProject.add方法的具体用法?Python CodeDoubanProject.add怎么用?Python CodeDoubanProject.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vilya.models.project.CodeDoubanProject的用法示例。


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

示例1: get_temp_project

# 需要导入模块: from vilya.models.project import CodeDoubanProject [as 别名]
# 或者: from vilya.models.project.CodeDoubanProject import add [as 别名]
def get_temp_project(origin=None, repo_path=BARE_REPO_PATH):
    if origin:
        prefix_path = get_repo_root()
        temp_repo_path = tempfile.mkdtemp(suffix=".git",
                                          prefix="test_",
                                          dir=prefix_path)
        project_name = temp_repo_path[len(prefix_path) + 1:][:-4]
        project = CodeDoubanProject.add(project_name,
                                        TEMP_PROJECT_OWNER,
                                        TEMP_PROJECT_DESCRIPTION,
                                        fork_from=origin.id,
                                        create_trac=False)
        return project

    prefix_path = get_repo_root()
    temp_repo_path = tempfile.mkdtemp(suffix=".git",
                                      prefix="test_",
                                      dir=prefix_path)
    project_name = temp_repo_path[len(prefix_path) + 1:][:-4]
    project = CodeDoubanProject.add(project_name, TEMP_PROJECT_OWNER,
                                    TEMP_PROJECT_DESCRIPTION)

    shutil.rmtree(temp_repo_path)
    repo = Jagare(repo_path)
    repo.clone(temp_repo_path, bare=True)

    return project
开发者ID:000fan000,项目名称:code,代码行数:29,代码来源:utils.py

示例2: test_fork_and_watch_project

# 需要导入模块: from vilya.models.project import CodeDoubanProject [as 别名]
# 或者: from vilya.models.project.CodeDoubanProject import add [as 别名]
    def test_fork_and_watch_project(self):
        p6 = CodeDoubanProject.add('project6', owner_id="admin_user",
                                   summary="test", product="fire")
        p7 = CodeDoubanProject.add('project7', owner_id="other_user",
                                   summary="test", product="fire")

        fork_count = CodeDoubanProject.get_forked_count(p6.id)
        p6fork = p6.fork('project6_other_user', 'other_user')
        fork_count2 = CodeDoubanProject.get_forked_count(p6.id)
        ok_(fork_count2 == fork_count + 1)
        ok_(CodeDoubanProject.get_forked_count(p6fork.id) == 0)

        p6fork2 = p6fork.fork('project6_fork_other_user', 'other_user')
        ok_(CodeDoubanProject.get_forked_count(p6.id) == fork_count + 2)
        ok_(CodeDoubanProject.get_forked_count(p6fork.id) == 1)
        ok_(CodeDoubanProject.get_forked_count(p6fork2.id) == 0)

        watch_count = CodeDoubanProject.get_watched_count(p7.id)
        CodeDoubanProject.add_watch(p7.id, 'admin_user')
        watch_count2 = CodeDoubanProject.get_watched_count(p7.id)
        ok_(watch_count2 == watch_count + 1)

        ok_(len(p7.get_watch_users()) == watch_count2)

        p6.delete()
        p7.delete()
开发者ID:000fan000,项目名称:code,代码行数:28,代码来源:test_project.py

示例3: test_multiple_project_index

# 需要导入模块: from vilya.models.project import CodeDoubanProject [as 别名]
# 或者: from vilya.models.project.CodeDoubanProject import add [as 别名]
 def test_multiple_project_index(self):
     skip_test()
     for i in range(5):
         CodeDoubanProject.add('test%s' % i, 'owner', create_trac=False)
     _reposearch.RepoSearch.index_repos()
     objs = _reposearch.RepoSearch.query_repo_objs()
     assert len(objs) == 5
开发者ID:leeccong,项目名称:code,代码行数:9,代码来源:test_search.py

示例4: test_transfer_project

# 需要导入模块: from vilya.models.project import CodeDoubanProject [as 别名]
# 或者: from vilya.models.project.CodeDoubanProject import add [as 别名]
 def test_transfer_project(self):
     pname1 = 'project6'
     pname2 = 'project7'
     proj_owner = 'admin_user'
     to_user = 'testuser1'
     p = CodeDoubanProject.add(pname1, owner_id=proj_owner,
                               summary="test", product="fire")
     _ = CodeDoubanProject.add(pname2, owner_id=proj_owner,
                               summary="test", product="fire")
     p.transfer_to(to_user)
     p1 = CodeDoubanProject.get_by_name(pname1)
     assert p1.owner_id == to_user
     p2 = CodeDoubanProject.get_by_name(pname2)
     assert p2.owner_id == proj_owner
开发者ID:000fan000,项目名称:code,代码行数:16,代码来源:test_project.py

示例5: setup_repos

# 需要导入模块: from vilya.models.project import CodeDoubanProject [as 别名]
# 或者: from vilya.models.project.CodeDoubanProject import add [as 别名]
def setup_repos(tmpdir, prj_name='test_proj'):
    origin_project = CodeDoubanProject.add(prj_name, 1,
                                           create_trac=False)
    path = origin_project.git_real_path
    with clone(path) as workdir:
        with open(os.path.join(workdir, 'origin'), 'w') as f:
            f.write(content_a)
    fork_project = CodeDoubanProject.add(prj_name + '_fork', 2,
                                         fork_from=origin_project.id,
                                         create_trac=False)
    fork_path = fork_project.git_real_path
    repo = origin_project
    fork_repo = fork_project
    return path, repo, fork_path, fork_repo
开发者ID:leeccong,项目名称:code,代码行数:16,代码来源:utils.py

示例6: test_get_my_projects

# 需要导入模块: from vilya.models.project import CodeDoubanProject [as 别名]
# 或者: from vilya.models.project.CodeDoubanProject import add [as 别名]
 def test_get_my_projects(self):
     project_name = "code"
     product_name = "fire"
     summary = "test"
     owner_id = "xingben"
     for i in range(5):
         delete_project("%s%d" % (project_name, i))
         CodeDoubanProject.add("%s%d" % (project_name, i), owner_id=owner_id, summary=summary, product=product_name)
     api_token = self.create_api_token("xingben")
     ret = self.app.get(
         "/api/user/repos", headers=dict(Authorization="Bearer %s" % api_token.token), status=200
     ).json
     self.assertEquals(len(ret), 5)
     self.assertTrue("name" in ret[0])
     self.assertTrue("description" in ret[0])
开发者ID:sdgdsffdsfff,项目名称:code-1,代码行数:17,代码来源:test_user.py

示例7: setUp

# 需要导入模块: from vilya.models.project import CodeDoubanProject [as 别名]
# 或者: from vilya.models.project.CodeDoubanProject import add [as 别名]
 def setUp(self):
     super(ProjectIssueCommentsTest, self).setUp()
     project_name = "code"
     product_name = "fire"
     summary = "test"
     owner_id = "lisong_intern"
     delete_project(project_name)
     project = CodeDoubanProject.add(
         project_name,
         owner_id=owner_id,
         summary=summary,
         product=product_name
     )
     self.project = project
     title = "test title"
     description = "test desc"
     creator = "test"
     issue = ProjectIssue.add(
         title,
         description,
         creator,
         project=self.project.id
     )
     self.issue = issue
     self.project = project
     self.comment1 = IssueComment.add(
         self.issue.issue_id, 'content1', 'test1')
     self.comment2 = IssueComment.add(
         self.issue.issue_id, 'content2', 'test2')
     self.api_token = self.create_api_token('test1')
     self.api_token2 = self.create_api_token('test2')
开发者ID:000fan000,项目名称:code,代码行数:33,代码来源:test_project_issue_comments.py

示例8: test_permissions_check

# 需要导入模块: from vilya.models.project import CodeDoubanProject [as 别名]
# 或者: from vilya.models.project.CodeDoubanProject import add [as 别名]
 def test_permissions_check(self):
     project_name = "project4"
     project = CodeDoubanProject.add(project_name, owner_id="admin_user",
                                     summary="test", product="fire")
     ok_(project.is_admin("admin_user"))
     ok_(not project.is_admin("other_user"))
     project.delete()
开发者ID:000fan000,项目名称:code,代码行数:9,代码来源:test_project.py

示例9: test_personal_project

# 需要导入模块: from vilya.models.project import CodeDoubanProject [as 别名]
# 或者: from vilya.models.project.CodeDoubanProject import add [as 别名]
    def test_personal_project(self):
        project_name = "lisong_intern/code"
        summary = "test"
        owner_id = "lisong_intern"
        delete_project(project_name)
        CodeDoubanProject.add(project_name, owner_id=owner_id, summary=summary)

        ret = self.app.get("/api/%s/" % project_name, status=200).json
        self.assertEqual(ret["name"], project_name)
        self.assertEqual(ret["owner"]["name"], owner_id)
        self.assertEqual(ret["description"], summary)
        self.assertEqual(ret["committers_count"], 0)
        self.assertEqual(ret["watched_count"], 0)
        self.assertEqual(ret["forked_count"], 0)
        self.assertEqual(ret["open_issues_count"], 0)
        self.assertEqual(ret["open_tickets_count"], 0)
开发者ID:sdgdsffdsfff,项目名称:code-1,代码行数:18,代码来源:test_projects.py

示例10: test_project_stat

# 需要导入模块: from vilya.models.project import CodeDoubanProject [as 别名]
# 或者: from vilya.models.project.CodeDoubanProject import add [as 别名]
    def test_project_stat(self):
        store.execute("delete from codedouban_projects where project_id < 5")
        project_rs = get_all_project()
        assert len(project_rs) == 0
        project_fork_count = len(filter(lambda x: x[1] is not None,
                                        project_rs))
        assert project_fork_count == 0

        project_name = "project"
        project = CodeDoubanProject.add(
            project_name, owner_id="test1", summary="test", product="fire")
        git_path = os.path.join(get_repo_root(), '%s.git' % project_name)
        ok_(os.path.exists(git_path))
        project_rs = get_all_project()
        assert len(project_rs) == 1
        project_fork_count = len(filter(lambda x: x[1] is not None,
                                        project_rs))
        assert project_fork_count == 0

        project_fork = project.fork('project_test_fork', 'test_fork')
        project_rs = get_all_project()
        assert len(project_rs) == 2
        project_fork_count = len(filter(lambda x: x[1] is not None,
                                        project_rs))
        assert project_fork_count == 1

        project.delete()
        project_fork.delete()
开发者ID:000fan000,项目名称:code,代码行数:30,代码来源:test_stat.py

示例11: add_people_project

# 需要导入模块: from vilya.models.project import CodeDoubanProject [as 别名]
# 或者: from vilya.models.project.CodeDoubanProject import add [as 别名]
 def add_people_project(project):
     name = "%s/%s" % (project.owner_id, project.name)
     _project = CodeDoubanProject.add(
         name=name, owner_id=project.owner_id,
         summary=project.summary, product=project.product,
         intern_banned=project.intern_banned)
     return _project
开发者ID:000fan000,项目名称:code,代码行数:9,代码来源:__init__.py

示例12: test_can_set_undefined_second_level_entry

# 需要导入模块: from vilya.models.project import CodeDoubanProject [as 别名]
# 或者: from vilya.models.project.CodeDoubanProject import add [as 别名]
 def test_can_set_undefined_second_level_entry(self):
     project = CodeDoubanProject.add(
         'tp', owner_id="test1", create_trac=False)
     u = self.addUser()
     project.git.commit_one_file(PROJECT_CONF_FILE,
                                 'docs: {unexisting_key: aaa}', 'm', u)
     assert project.conf['docs']['unexisting_key'] == 'aaa'
开发者ID:leeccong,项目名称:code,代码行数:9,代码来源:test_project_conf.py

示例13: test_broken_conf

# 需要导入模块: from vilya.models.project import CodeDoubanProject [as 别名]
# 或者: from vilya.models.project.CodeDoubanProject import add [as 别名]
 def test_broken_conf(self):
     project = CodeDoubanProject.add(
         'tp', owner_id="test1", create_trac=False)
     u = self.addUser()
     project.git.commit_one_file(PROJECT_CONF_FILE,
                                 'docs {dir: other_dir', 'm', u)
     assert project.conf['docs']['dir'] == 'other_dir'
开发者ID:leeccong,项目名称:code,代码行数:9,代码来源:test_project_conf.py

示例14: test_project_meta_dict

# 需要导入模块: from vilya.models.project import CodeDoubanProject [as 别名]
# 或者: from vilya.models.project.CodeDoubanProject import add [as 别名]
 def test_project_meta_dict(self):
     project_name = "project3"
     owner_id = "testuser"
     summary = "a summary"
     product = "fire"
     project = CodeDoubanProject.add(
         project_name, owner_id, summary, product)
     # hookfile_path = "%s/hooks/post-receive" % project.git_real_path
     project = CodeDoubanProject.get_by_name(project_name)
     data = {
         'url': "%s/%s" % (DOMAIN, project_name),
         'name': project_name,
         'description': summary,
         'product': product,
         'committers_count': 0,
         'forked_count': 0,
         'open_issues_count': 0,
         'open_tickets_count': 0,
         'watched_count': 0,
         'owner': {
             'name': owner_id,
             'avatar': gravatar_url(owner_id + '@douban.com'),
         },
     }
     commits = project.git.get_revisions("HEAD~1", "HEAD")
     if commits:
         data['last_commit'] = commits[0]
     ok_(project.get_info() == data)
     project.delete()
开发者ID:000fan000,项目名称:code,代码行数:31,代码来源:test_project.py

示例15: test_create_project

# 需要导入模块: from vilya.models.project import CodeDoubanProject [as 别名]
# 或者: from vilya.models.project.CodeDoubanProject import add [as 别名]
    def test_create_project(self):
        project_name = "project"
        project = CodeDoubanProject.add(
            project_name, owner_id="test1", summary="test", product="fire")

        git_path = os.path.join(get_repo_root(), '%s.git' % project_name)
        ok_(os.path.exists(git_path))
        project.delete()
开发者ID:000fan000,项目名称:code,代码行数:10,代码来源:test_project.py


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