本文整理汇总了Python中forgetracker.model.Ticket.new方法的典型用法代码示例。如果您正苦于以下问题:Python Ticket.new方法的具体用法?Python Ticket.new怎么用?Python Ticket.new使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forgetracker.model.Ticket
的用法示例。
在下文中一共展示了Ticket.new方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_ticket_move_with_users_not_in_project
# 需要导入模块: from forgetracker.model import Ticket [as 别名]
# 或者: from forgetracker.model.Ticket import new [as 别名]
def test_ticket_move_with_users_not_in_project(self):
app1 = c.project.app_instance('bugs')
app2 = c.project.app_instance('bugs2')
app1.globals.custom_fields.extend([
{'name': '_user_field', 'type': 'user', 'label': 'User field'},
{'name': '_user_field_2', 'type': 'user', 'label': 'User field 2'}])
app2.globals.custom_fields.extend([
{'name': '_user_field', 'type': 'user', 'label': 'User field'},
{'name': '_user_field_2', 'type': 'user', 'label': 'User field 2'}])
ThreadLocalORMSession.flush_all()
ThreadLocalORMSession.close_all()
from allura.websetup import bootstrap
bootstrap.create_user('test-user-0')
with h.push_context(c.project._id, app_config_id=app1.config._id):
ticket = Ticket.new()
ticket.summary = 'test ticket'
ticket.description = 'test description'
ticket.custom_fields['_user_field'] = 'test-user' # in project
ticket.custom_fields['_user_field_2'] = 'test-user-0' # not in project
ticket.assigned_to_id = User.by_username('test-user-0')._id # not in project
t = ticket.move(app2.config)
assert_equal(t.assigned_to_id, None)
assert_equal(t.custom_fields['_user_field'], 'test-user')
assert_equal(t.custom_fields['_user_field_2'], '')
post = Post.query.find(dict(thread_id=ticket.discussion_thread._id)).first()
assert post is not None, 'No comment about ticket moving'
message = 'Ticket moved from /p/test/bugs/1/'
message += '\n\nCan\'t be converted:\n'
message += '\n- **_user_field_2**: test-user-0 (user not in project)'
message += '\n- **assigned_to**: test-user-0 (user not in project)'
assert_equal(post.text, message)
示例2: test_ticket_move_with_different_custom_fields
# 需要导入模块: from forgetracker.model import Ticket [as 别名]
# 或者: from forgetracker.model.Ticket import new [as 别名]
def test_ticket_move_with_different_custom_fields(self):
app1 = c.project.app_instance('bugs')
app2 = c.project.app_instance('bugs2')
app1.globals.custom_fields.extend([
{'name': '_test', 'type': 'string', 'label': 'Test field'},
{'name': '_test2', 'type': 'string', 'label': 'Test field 2'}])
app2.globals.custom_fields.append(
{'name': '_test', 'type': 'string', 'label': 'Test field'})
ThreadLocalORMSession.flush_all()
ThreadLocalORMSession.close_all()
with h.push_context(c.project._id, app_config_id=app1.config._id):
ticket = Ticket.new()
ticket.summary = 'test ticket'
ticket.description = 'test description'
ticket.custom_fields['_test'] = 'test val'
ticket.custom_fields['_test2'] = 'test val 2'
t = ticket.move(app2.config)
assert_equal(t.summary, 'test ticket')
assert_equal(t.description, 'test description')
assert_equal(t.custom_fields['_test'], 'test val')
post = Post.query.find(dict(thread_id=ticket.discussion_thread._id)).first()
assert post is not None, 'No comment about ticket moving'
message = 'Ticket moved from /p/test/bugs/1/'
message += '\n\nCan\'t be converted:\n'
message += '\n- **_test2**: test val 2'
assert_equal(post.text, message)
示例3: test_json_parents
# 需要导入模块: from forgetracker.model import Ticket [as 别名]
# 或者: from forgetracker.model.Ticket import new [as 别名]
def test_json_parents(self):
ticket = Ticket.new()
json_keys = ticket.__json__().keys()
assert_in('related_artifacts', json_keys) # from Artifact
assert_in('votes_up', json_keys) # VotableArtifact
assert_in('ticket_num', json_keys) # Ticket
assert ticket.__json__()['assigned_to'] is None
示例4: test_ticket_move
# 需要导入模块: from forgetracker.model import Ticket [as 别名]
# 或者: from forgetracker.model.Ticket import new [as 别名]
def test_ticket_move(self):
app1 = c.project.app_instance('bugs')
app2 = c.project.app_instance('bugs2')
with h.push_context(c.project._id, app_config_id=app1.config._id):
ticket = Ticket.new()
ticket.summary = 'test ticket'
ticket.description = 'test description'
ticket.assigned_to_id = User.by_username('test-user')._id
ticket.discussion_thread.add_post(text='test comment')
assert_equal(Ticket.query.find({'app_config_id': app1.config._id}).count(), 1)
assert_equal(Ticket.query.find({'app_config_id': app2.config._id}).count(), 0)
assert_equal(Post.query.find(dict(thread_id=ticket.discussion_thread._id)).count(), 1)
t = ticket.move(app2.config)
assert_equal(Ticket.query.find({'app_config_id': app1.config._id}).count(), 0)
assert_equal(Ticket.query.find({'app_config_id': app2.config._id}).count(), 1)
assert_equal(t.summary, 'test ticket')
assert_equal(t.description, 'test description')
assert_equal(t.assigned_to.username, 'test-user')
assert_equal(t.url(), '/p/test/bugs2/1/')
post = Post.query.find(dict(thread_id=ticket.discussion_thread._id,
text={'$ne': 'test comment'})).first()
assert post is not None, 'No comment about ticket moving'
message = 'Ticket moved from /p/test/bugs/1/'
assert_equal(post.text, message)
post = Post.query.find(dict(text='test comment')).first()
assert_equal(post.thread.discussion_id, app2.config.discussion_id)
assert_equal(post.thread.app_config_id, app2.config._id)
assert_equal(post.app_config_id, app2.config._id)
示例5: test_attach_with_resettable_stream
# 需要导入模块: from forgetracker.model import Ticket [as 别名]
# 或者: from forgetracker.model.Ticket import new [as 别名]
def test_attach_with_resettable_stream(self):
with h.push_context(c.project._id, app_config_id=c.app.config._id):
ticket = Ticket.new()
ticket.summary = 'test ticket'
ticket.description = 'test description'
assert_equal(len(ticket.attachments), 0)
f = urllib2.urlopen('file://%s' % __file__)
TicketAttachment.save_attachment('test_ticket_model.py', ResettableStream(f),
artifact_id=ticket._id)
ThreadLocalORMSession.flush_all()
# need to refetch since attachments are cached
session(ticket).expunge(ticket)
ticket = Ticket.query.get(_id=ticket._id)
assert_equal(len(ticket.attachments), 1)
assert_equal(ticket.attachments[0].filename, 'test_ticket_model.py')