本文整理汇总了Python中vilya.models.project.CodeDoubanProject类的典型用法代码示例。如果您正苦于以下问题:Python CodeDoubanProject类的具体用法?Python CodeDoubanProject怎么用?Python CodeDoubanProject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CodeDoubanProject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_git_repo
def test_create_git_repo(self):
git_path = os.path.join(get_repo_root(), "abc.git")
CodeDoubanProject.create_git_repo(git_path)
assert os.path.exists(git_path)
info_file = os.path.join(git_path, "refs")
assert os.path.exists(info_file)
shutil.rmtree(git_path)
示例2: _q_index
def _q_index(request):
user = request.user
my_issues = []
if user:
username = user.username
your_projects = CodeDoubanProject.get_projects(owner=username,
sortby='lru')
watched_projects = CodeDoubanProject.get_watched_others_projects_by_user( # noqa
user=username,
sortby='lru')
teams = Team.get_by_user_id(user.name)
actions = get_user_inbox(username).get_actions(
stop=PAGE_ACTIONS_COUNT - 1)
badge_items = user.get_badge_items()
# pull request
# your_tickets = user.get_user_pull_requests_rank(limit=5)
your_tickets = user.get_user_submit_pull_requests(limit=5)
# issue
project_ids = CodeDoubanProject.get_ids(user.name)
dt = {
'state': "open",
'limit': 5,
'start': 0,
}
my_issues = ProjectIssue.gets_by_project_ids(project_ids, **dt)
return st('newsfeed.html', **locals())
return request.redirect("/teams/")
示例3: create
def create(self, request):
user = request.user
if not user:
raise AccessError
from_proj = request.get_form_var('from_proj')
from_ref = request.get_form_var('from_ref')
to_ref = request.get_form_var('to_ref')
to_proj = request.get_form_var('to_proj')
title = request.get_form_var('title', '').decode('utf-8')
comment = request.get_form_var('body', '').decode('utf-8')
if not all([from_ref, from_proj, to_ref, to_proj]):
raise TraversalError
from_proj = CodeDoubanProject.get_by_name(from_proj)
to_proj = CodeDoubanProject.get_by_name(to_proj)
if from_proj != to_proj:
if not from_proj.has_push_perm(user.name):
raise AccessError(
"Need push permission to create PR on another project")
pullreq = PullRequest.open(from_proj, from_ref, to_proj, to_ref)
ticket = Ticket(None, None, to_proj.id, title, comment,
user.username, None, None)
pullreq = add_pull(ticket, pullreq, user)
ticket = pullreq.ticket
return request.redirect(str('/%s/pull/%s/' % (to_proj.name,
ticket.ticket_id)))
示例4: test_multiple_project_index
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
示例5: test_project_meta_dict
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()
示例6: get_temp_project
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
示例7: test_destroy_hook
def test_destroy_hook(self):
url = "http://this.is.other.url"
prj = self._prj()
hook = CodeDoubanHook.add(url, prj.id)
hooked_project = CodeDoubanProject.get(hook.project_id)
assert len(hooked_project.hooks) == 1
hooked_project = CodeDoubanProject.get(hook.project_id)
hook.destroy()
assert len(hooked_project.hooks) == 0
示例8: test_get_forked_from_should_return_origin_project
def test_get_forked_from_should_return_origin_project(self):
prj = CodeDoubanProject.get_by_name('orig')
prj.delete()
prj = CodeDoubanProject.get_by_name('fork')
prj.delete()
orig = CodeDoubanProject.add('orig', owner_id="test1")
fork = orig.fork('fork', 'user2')
source = fork.get_forked_from()
eq_(source, orig)
示例9: test_project_validate
def test_project_validate(self):
noname_project = CodeDoubanProject(
108, '', "test1", "testuser", datetime.now(), "fire",
'/fake_path', '/fake_path')
ok_project = CodeDoubanProject(
108, 'project6', "testuser", datetime.now(), "test",
"fire", '/fake_path', '/fake_path')
ok_(bool(noname_project.validate()))
ok_(not bool(ok_project.validate()))
示例10: _repo
def _repo(self, name, bare=True):
git_path = self._path(name)
if bare:
work_tree_path = None
else:
work_tree_path = self._path_work_tree(name)
os.mkdir(work_tree_path)
CodeDoubanProject.create_git_repo(git_path)
repo = git.GitRepo(git_path, work_tree=work_tree_path)
return repo
示例11: test_create
def test_create(self):
git_path = os.path.join(get_repo_root(), 'test_create.git')
assert not os.path.exists(
git_path), "git_path should not exist prior repo creation"
CodeDoubanProject.create_git_repo(git_path)
assert os.path.exists(
git_path), "create_git_repo should create git_path"
refs_file = os.path.join(git_path, 'refs')
assert os.path.exists(refs_file), \
"create_git_repo should create a git repo with refs subdir"
示例12: yours
def yours(request):
user = request.user
actions = (get_user_feed(user.username)
.get_actions(stop=PAGE_ACTIONS_COUNT - 1))
your_projects = CodeDoubanProject.get_projects(
owner=user.username, sortby="lru")
watched_projects = CodeDoubanProject.get_watched_others_projects_by_user(
user=user.username, sortby='lru')
badge_items = user.get_badge_items()
return st('my_actions.html', **locals())
示例13: add_fork_project
def add_fork_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, fork_from=project.fork_from,
intern_banned=project.intern_banned)
if _project:
fork_from_project = CodeDoubanProject.get(project.fork_from)
_project.update(project.summary,
project.product,
name,
fork_from_project.intern_banned)
return _project
示例14: test_get_fork_network_should_return_all_projects_with_same_origin
def test_get_fork_network_should_return_all_projects_with_same_origin(self): # noqa
prj = CodeDoubanProject.get_by_name('orig')
prj.delete()
orig = CodeDoubanProject.add('orig', owner_id="test1")
fork = orig.fork('fork1', 'user1')
fork2 = orig.fork('fork2', 'user2')
fork3 = fork.fork('fork3', 'user3')
expected_network = set([orig, fork, fork2, fork3])
for proj in [orig, fork, fork2, fork3]:
network = proj.get_fork_network()
eq_(set(network), expected_network)
示例15: update_repo_indexes
def update_repo_indexes(cls):
old_obj_ids = cls.query_repo_objs()
old_obj_ids = [id for id, in old_obj_ids]
new_obj_ids = CodeDoubanProject.get_project_ids_sortby_sumup()
new_objs = CodeDoubanProject.gets(new_obj_ids)
to_delete_ids = set(old_obj_ids) - set(new_obj_ids)
cls.delete_repo_indexes(to_delete_ids)
index_data = [cls.get_repo_index_from_project(project)
for project in new_objs]
indexes = [(data['id'], data) for data in index_data]
IndexEngine.create_index_bulk('repo', indexes)