本文整理汇总了Python中vilya.models.ticket.Ticket.add方法的典型用法代码示例。如果您正苦于以下问题:Python Ticket.add方法的具体用法?Python Ticket.add怎么用?Python Ticket.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vilya.models.ticket.Ticket
的用法示例。
在下文中一共展示了Ticket.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_ticket_gets_by_proj_and_author
# 需要导入模块: from vilya.models.ticket import Ticket [as 别名]
# 或者: from vilya.models.ticket.Ticket import add [as 别名]
def test_ticket_gets_by_proj_and_author(self):
title = 'test title'
desc = 'test desc'
author = 'testuser'
Ticket.add(self.proj1.id, title, desc, author)
assert Ticket.gets_by_proj_and_author(self.proj1.id, author)
assert not Ticket.gets_by_proj_and_author(
self.proj1.id, author='anonuser')
示例2: test_ticket_count
# 需要导入模块: from vilya.models.ticket import Ticket [as 别名]
# 或者: from vilya.models.ticket.Ticket import add [as 别名]
def test_ticket_count(self):
title = 'test title'
desc = 'test desc'
author = 'testuser'
p1_t1 = Ticket.add(self.proj1.id, title, desc, author)
pullreq1 = PullRequest.open(
self.proj1_fork, 'master', self.proj1, 'master')
pullreq1 = pullreq1.insert(p1_t1.ticket_number)
p1_t2 = Ticket.add(self.proj1.id, title, desc, author)
pullreq = PullRequest.open(
self.proj1_fork, 'master', self.proj1, 'master')
pullreq = pullreq.insert(p1_t2.ticket_number)
# test ticket count
assert int(Ticket.get_count_by_proj(self.proj1.id)) == 2
示例3: test_get_user_submitted_pull_requests
# 需要导入模块: from vilya.models.ticket import Ticket [as 别名]
# 或者: from vilya.models.ticket.Ticket import add [as 别名]
def test_get_user_submitted_pull_requests(self):
title = 'test title'
desc = 'test desc'
u = User('testu%s' % time.time())
p1_t1 = Ticket.add(self.proj1.id, title, desc, u.username)
assert u.get_user_submit_pull_requests() != []
assert u.n_user_open_submit_pull_requests == 1
p1_t1.close('testuser')
assert u.get_user_submit_pull_requests() == []
assert u.n_user_open_submit_pull_requests == 0
assert u.n_open_pull_requests == 0
示例4: test_pr_stat
# 需要导入模块: from vilya.models.ticket import Ticket [as 别名]
# 或者: from vilya.models.ticket.Ticket import add [as 别名]
def test_pr_stat(self):
TestCase.setUp(self)
_, self.proj1, _, self.proj1_fork = setup_repos(
mkdtemp(), 'testproject1')
_, self.proj2, _, self.proj2_fork = setup_repos(
mkdtemp(), 'testproject2')
pr_rs = get_all_ticket()
assert len(pr_rs) == 0
pr_open_count = len(filter(lambda x: x[1] is None, pr_rs))
assert pr_open_count == 0
assert len(pr_rs) - pr_open_count == 0
pullreq1 = PullRequest.open(
self.proj1_fork, 'master', self.proj1, 'master')
ticket1 = Ticket.add(self.proj1.id, 'title', 'content', 'testuser')
pullreq1 = pullreq1.insert(ticket1.ticket_number)
pullreq2 = PullRequest.open(
self.proj2_fork, 'master', self.proj2, 'master')
ticket2 = Ticket.add(self.proj2.id, 'title', 'content', 'testuser')
pullreq2 = pullreq2.insert(ticket2.ticket_number)
pr_rs = get_all_ticket()
assert len(pr_rs) == 2
pr_open_count = len(filter(lambda x: x[1] is None, pr_rs))
assert pr_open_count == 2
assert len(pr_rs) - pr_open_count == 0
ticket1.close("testuser")
pr_rs = get_all_ticket()
assert len(pr_rs) == 2
pr_open_count = len(filter(lambda x: x[1] is None, pr_rs))
assert pr_open_count == 1
assert len(pr_rs) - pr_open_count == 1
pr_comment_count = get_ticket_comment_count()
assert(pr_comment_count) == 0
ticket2.add_comment("comment1", "testuse1")
ticket2.add_comment("comment2", "testuse2")
pr_comment_count = get_ticket_comment_count()
assert(pr_comment_count) == 2
示例5: test_ticket_close
# 需要导入模块: from vilya.models.ticket import Ticket [as 别名]
# 或者: from vilya.models.ticket.Ticket import add [as 别名]
def test_ticket_close(self):
# close ticket
title = 'test title'
desc = 'test desc'
author = 'testuser'
p2_t1 = Ticket.add(self.proj2.id, title, desc, author)
pullreq2 = PullRequest.open(
self.proj2_fork, 'master', self.proj2, 'master')
pullreq2 = pullreq2.insert(p2_t1.ticket_number)
assert p2_t1.closed is None
p2_t1.close('testuser')
assert Ticket.get(p2_t1.id).closed is not None
示例6: test_ticket
# 需要导入模块: from vilya.models.ticket import Ticket [as 别名]
# 或者: from vilya.models.ticket.Ticket import add [as 别名]
def test_ticket(self):
title = 'test title'
desc = 'test desc'
author = 'testuser'
p1_t1 = Ticket.add(self.proj1.id, title, desc, author)
pullreq1 = PullRequest.open(
self.proj1_fork, 'master', self.proj1, 'master')
pullreq1 = pullreq1.insert(p1_t1.ticket_number)
assert p1_t1.ticket_id == 1
assert p1_t1.title == title
assert p1_t1.description == desc
assert p1_t1.author == author
p2_t1 = Ticket.add(self.proj2.id, title, desc, author)
pullreq2 = PullRequest.open(
self.proj2_fork, 'master', self.proj2, 'master')
pullreq2 = pullreq2.insert(p2_t1.ticket_number)
assert p2_t1.ticket_id == 1
ticket = Ticket.get_by_projectid_and_ticketnumber(
self.proj1.id, p1_t1.ticket_id)
assert ticket.id == p1_t1.id
ticket = Ticket.get_by_projectid_and_ticketnumber(
self.proj2.id, p2_t1.ticket_id)
assert ticket.id == p2_t1.id
示例7: test_count_ticket_rank
# 需要导入模块: from vilya.models.ticket import Ticket [as 别名]
# 或者: from vilya.models.ticket.Ticket import add [as 别名]
def test_count_ticket_rank(self):
clean_up()
title = 'test title'
desc = 'test desc'
author = 'testuser'
tick1 = Ticket.add(1, title, desc, author)
tick2 = Ticket.add(2, title, desc, author)
created_at = datetime.now()
aDay = timedelta(days=-1)
yesterday = created_at + aDay
node1 = TicketNode.add(
TICKET_NODE_TYPE_COMMENT, 0, 'user1', tick1.id, created_at)
node2 = TicketNode.add(
TICKET_NODE_TYPE_COMMENT, 0, 'user1', tick1.id, created_at)
node3 = TicketNode.add(
TICKET_NODE_TYPE_LINECOMMENT, 0, 'user1', tick1.id, created_at)
node4 = TicketNode.add(
TICKET_NODE_TYPE_COMMENT, 0, 'user1', tick2.id, yesterday)
node5 = TicketNode.add(
TICKET_NODE_TYPE_LINECOMMENT, 0, 'user1', tick2.id, yesterday)
# 验证 已经关闭的 ticket
store.execute("update codedouban_ticket set time=%s, closed=%s "
"where id=%s", (yesterday, created_at, tick2.id))
store.commit()
TicketRank.count_ticket_rank(True)
rank_score2 = TicketRank.get_rank_by_ticket_id(tick2.id)
rank_s2 = rank_score2[0][0]
rank2 = 32.07
assert rank_s2 == rank2
# 验证 没有关闭的 ticket
TicketRank.count_ticket_rank(False)
rank_score1 = TicketRank.get_rank_by_ticket_id(tick1.id)
rank_s1 = rank_score1[0][0]
rank1 = 37.97
assert rank_s1 == rank1
示例8: test_ticket_commit
# 需要导入模块: from vilya.models.ticket import Ticket [as 别名]
# 或者: from vilya.models.ticket.Ticket import add [as 别名]
def test_ticket_commit(self):
title = 'test title'
desc = 'test desc'
author = 'testuser'
p1_t1 = Ticket.add(self.proj1.id, title, desc, author)
pullreq1 = PullRequest.open(
self.proj1_fork, 'master', self.proj1, 'master')
pullreq1 = pullreq1.insert(p1_t1.ticket_number)
# ticket commits
commits_value = '454418c61cd7ef1a65818121746b45064a5af5d6,454418c61cd7ef1a65818121746b45064a5af574' # noqa
p1_t1.add_commits(commits_value, author)
commits = p1_t1.get_commits()
assert len(commits) == 1
assert commits[0].commits == commits_value
示例9: test_pullrequest
# 需要导入模块: from vilya.models.ticket import Ticket [as 别名]
# 或者: from vilya.models.ticket.Ticket import add [as 别名]
def test_pullrequest(self):
pullreq1 = PullRequest.open(
self.proj1_fork, 'master', self.proj1, 'master')
ticket1 = Ticket.add(self.proj1.id, 'title', 'content', 'testuser')
pullreq1.insert(ticket1.ticket_number)
pullreq2 = PullRequest.open(
self.proj2_fork, 'master', self.proj2, 'master')
ticket2 = Ticket.add(self.proj2.id, 'title', 'content', 'testuser')
pullreq2.insert(ticket2.ticket_number)
opened_prs = self.proj1_fork.open_parent_pulls
assert len(opened_prs) == 1
opened_prs = self.proj2_fork.open_parent_pulls
assert len(opened_prs) == 1
ticket1.close('testuser')
opened_prs = self.proj1_fork.open_parent_pulls
assert len(opened_prs) == 0
ticket2.close('testuser')
opened_prs = self.proj2_fork.open_parent_pulls
assert len(opened_prs) == 0
示例10: test_ticket_update_desc
# 需要导入模块: from vilya.models.ticket import Ticket [as 别名]
# 或者: from vilya.models.ticket.Ticket import add [as 别名]
def test_ticket_update_desc(self):
title = 'test title'
desc = 'test desc'
author = 'testuser'
p1_t2 = Ticket.add(self.proj1.id, title, desc, author)
pullreq = PullRequest.open(
self.proj1_fork, 'master', self.proj1, 'master')
pullreq = pullreq.insert(p1_t2.ticket_number)
new_title = 'this is new title'
new_desc = 'this is new desc!'
p1_t2.update(new_title, new_desc)
p1_t2 = Ticket.get(p1_t2.id)
assert p1_t2.title == new_title
assert p1_t2.description == new_desc
示例11: test_get_user_pull_requests
# 需要导入模块: from vilya.models.ticket import Ticket [as 别名]
# 或者: from vilya.models.ticket.Ticket import add [as 别名]
def test_get_user_pull_requests(self):
u = User('testu%s' % time.time())
title = 'test title'
desc = 'test desc'
t1 = Ticket.add(self.proj1.id, title, desc, u.username)
assert u.get_invited_pull_requests() == []
u.add_invited_pull_request(t1.id)
print u.get_invited_pull_requests()
assert u.get_invited_pull_requests()[0].id == t1.id
assert u.n_open_invited == 1
assert u.get_participated_pull_requests()[0].id == t1.id
u.add_participated_pull_request(t1.id)
assert u.get_participated_pull_requests()[0].id == t1.id
assert u.n_open_participated == 1
示例12: test_ticket_participants
# 需要导入模块: from vilya.models.ticket import Ticket [as 别名]
# 或者: from vilya.models.ticket.Ticket import add [as 别名]
def test_ticket_participants(self):
# test participants
title = 'test title'
desc = 'test desc'
author = 'testuser'
p1_t2 = Ticket.add(self.proj1.id, title, desc, author)
pullreq = PullRequest.open(
self.proj1_fork, 'master', self.proj1, 'master')
pullreq = pullreq.insert(p1_t2.ticket_number)
assert len(p1_t2.participants) == 1
assert p1_t2.participants[0] == author
user2 = 'testuser2'
p1_t2.add_comment('comment contet', user2)
assert len(p1_t2.participants) == 2
assert p1_t2.participants[0] == author
assert p1_t2.participants[1] == user2
示例13: test_ticket_code_review
# 需要导入模块: from vilya.models.ticket import Ticket [as 别名]
# 或者: from vilya.models.ticket.Ticket import add [as 别名]
def test_ticket_code_review(self):
title = 'test title'
desc = 'test desc'
author = 'testuser'
p1_t1 = Ticket.add(self.proj1.id, title, desc, author)
pullreq1 = PullRequest.open(
self.proj1_fork, 'master', self.proj1, 'master')
pullreq1 = pullreq1.insert(p1_t1.ticket_number)
# ticket code review
path = '/README.md'
#position = 10
from_sha = '454418c61cd7ef1a65818121746b45064a5af5d6'
oid = '454418c61cd7ef1a65818121746b45064a5af5d6'
codereview = p1_t1.add_codereview(
from_sha, '', path, path, oid, oid, LINECOMMENT_INDEX_EMPTY,
LINECOMMENT_INDEX_EMPTY, author, 'comment content')
assert codereview.ticket_id == p1_t1.id
assert codereview.path == path
assert codereview.from_sha == from_sha
#test update content
assert codereview.content == 'comment content'
codereview.update('content updated')
codereview = PullLineComment.get(codereview.id)
assert codereview.content == 'content updated'
codereviews = PullLineComment.gets_by_target_and_ref(
p1_t1.id, from_sha)
assert len(codereviews) == 1
p1_t1.add_codereview(
from_sha, '', path, path, oid, oid, LINECOMMENT_INDEX_EMPTY,
LINECOMMENT_INDEX_EMPTY, author, 'another comment content')
codereviews = PullLineComment.gets_by_target_and_ref(
p1_t1.id, from_sha)
assert len(codereviews) == 2
#test delete comment
codereview.delete()
codereviews = PullLineComment.gets_by_target_and_ref(
p1_t1.id, from_sha)
assert len(codereviews) == 1
示例14: test_ticket_comment
# 需要导入模块: from vilya.models.ticket import Ticket [as 别名]
# 或者: from vilya.models.ticket.Ticket import add [as 别名]
def test_ticket_comment(self):
title = 'test title'
desc = 'test desc'
author = 'testuser'
p1_t1 = Ticket.add(self.proj1.id, title, desc, author)
pullreq1 = PullRequest.open(
self.proj1_fork, 'master', self.proj1, 'master')
pullreq1 = pullreq1.insert(p1_t1.ticket_number)
# add ticket comment
comment = p1_t1.add_comment('comment contet', author)
assert comment is not None
# update ticket_comment
assert comment.content == 'comment contet'
comment.update('comment content updated')
comment = TicketComment.get(id=comment.id)
assert comment.content == 'comment content updated'
# delete ticket_comment
assert len(TicketComment.gets_by_ticketid(p1_t1.id)) == 1
comment.delete()
assert TicketComment.gets_by_ticketid(p1_t1.id) == []
示例15: add_pull
# 需要导入模块: from vilya.models.ticket import Ticket [as 别名]
# 或者: from vilya.models.ticket.Ticket import add [as 别名]
def add_pull(ticket, pullreq, user):
from dispatches import dispatch
from vilya.libs.text import get_mentions_from_text
from vilya.libs.signals import pullrequest_signal
from vilya.models.user import get_author_by_email
from vilya.models.user import User
from vilya.models.trello.core import process_trello_notify
reporter = user.username
commits = pullreq.commits
# TODO: refactory is! auto number how to?
shas = [p.sha for p in commits]
ticket_len = Ticket.get_count_by_proj_id(ticket.project_id)
if ticket_len == 0:
# 检查是否创建过新PR,若未创建过则以旧PR号为基准累加
max_ticket_id = PullRequest.get_max_ticket_id(ticket.project_id)
if max_ticket_id >= 0:
ticket = Ticket.add(ticket.project_id,
ticket.title,
ticket.description,
ticket.author,
max_ticket_id + 1)
else:
ticket = Ticket.add(ticket.project_id,
ticket.title,
ticket.description,
ticket.author)
else:
ticket = Ticket.add(ticket.project_id,
ticket.title,
ticket.description,
ticket.author)
pullreq = pullreq.insert(ticket.ticket_number)
if shas:
ticket.add_commits(','.join(shas), reporter)
noti_receivers = [committer.name
for committer in CodeDoubanProject.get_committers_by_project(pullreq.to_proj.id)] # noqa
noti_receivers = noti_receivers + [pullreq.to_proj.owner.name]
get_commit_author = lambda u: get_author_by_email(u.email.encode('utf-8'))
commit_authors = {get_commit_author(c.author) for c in commits}
commit_authors = {a for a in commit_authors if a}
noti_receivers.extend(commit_authors)
# diffs, author_by_file, authors = pullreq.get_diffs(with_blame=True)
# FIXME: diffs没用到?
# diffs = pullreq.get_diffs()
# blame代码变更的原作者, 也加到at users
at_users = get_mentions_from_text(ticket.description)
# at_users.extend(authors)
at_users.append(pullreq.to_proj.owner_id)
at_users = set(at_users)
# FIXME: invited_users is used on page /hub/my_pull_requests/
invited_users = [User(u).add_invited_pull_request(ticket.id)
for u in at_users]
ProjectOwnLRUCounter(user.username).use(pullreq.to_proj.id)
ProjectWatchLRUCounter(user.username).use(pullreq.to_proj.id)
# TODO: 重构Feed之后取消这个信号的发送
pullrequest_signal.send(user.username,
extra_receivers=noti_receivers,
pullreq=pullreq,
comment=ticket.description,
ticket_id=ticket.ticket_id,
ticket=ticket,
status="unmerge",
new_version=True)
dispatch('pullreq',
data=dict(sender=user.username,
content=ticket.description,
ticket=ticket,
status='unmerge',
new_version=True,
extra_receivers=noti_receivers))
dispatch('pr_actions',
data=dict(type='pr_opened',
hooks=pullreq.to_proj.hooks,
author=user,
title=ticket.title,
body=ticket.description,
ticket=ticket,
pullreq=pullreq))
# FIXME: move to dispatch
process_trello_notify(user, ticket)
return pullreq