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


Python model.Ticket类代码示例

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


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

示例1: test_ticket_num_required2

 def test_ticket_num_required2(self):
     t = Ticket(summary='my ticket', ticket_num=12)
     try:
         t.ticket_num = None
     except schema.Invalid:
         pass
     else:
         raise AssertionError('Expected schema.Invalid to be thrown')
开发者ID:johnsca,项目名称:incubator-allura,代码行数:8,代码来源:test_ticket_model.py

示例2: test_private_ticket

    def test_private_ticket(self):
        from pylons import c
        from allura.model import ProjectRole, User
        from allura.model import ACE, ALL_PERMISSIONS, DENY_ALL
        from allura.lib.security import Credentials, has_access
        from allura.websetup import bootstrap

        admin = c.user
        creator = bootstrap.create_user('Not a Project Admin')
        developer = bootstrap.create_user('Project Developer')
        observer = bootstrap.create_user('Random Non-Project User')
        anon = User(_id=None, username='*anonymous',
                    display_name='Anonymous')
        t = Ticket(summary='my ticket', ticket_num=3, reported_by_id=creator._id)

        assert creator == t.reported_by
        role_admin = ProjectRole.by_name('Admin')._id
        role_developer = ProjectRole.by_name('Developer')._id
        role_creator = t.reported_by.project_role()._id
        developer.project_role().roles.append(role_developer)
        cred = Credentials.get().clear()

        t.private = True
        assert t.acl == [ACE.allow(role_developer, ALL_PERMISSIONS),
                         ACE.allow(role_creator, ALL_PERMISSIONS),
                         DENY_ALL]
        assert has_access(t, 'read', user=admin)()
        assert has_access(t, 'create', user=admin)()
        assert has_access(t, 'update', user=admin)()
        assert has_access(t, 'read', user=creator)()
        assert has_access(t, 'create', user=creator)()
        assert has_access(t, 'update', user=creator)()
        assert has_access(t, 'read', user=developer)()
        assert has_access(t, 'create', user=developer)()
        assert has_access(t, 'update', user=developer)()
        assert not has_access(t, 'read', user=observer)()
        assert not has_access(t, 'create', user=observer)()
        assert not has_access(t, 'update', user=observer)()
        assert not has_access(t, 'read', user=anon)()
        assert not has_access(t, 'create', user=anon)()
        assert not has_access(t, 'update', user=anon)()

        t.private = False
        assert t.acl == []
        assert has_access(t, 'read', user=admin)()
        assert has_access(t, 'create', user=admin)()
        assert has_access(t, 'update', user=admin)()
        assert has_access(t, 'read', user=developer)()
        assert has_access(t, 'create', user=developer)()
        assert has_access(t, 'update', user=developer)()
        assert has_access(t, 'read', user=creator)()
        assert has_access(t, 'unmoderated_post', user=creator)()
        assert not has_access(t, 'create', user=creator)()
        assert not has_access(t, 'update', user=creator)()
        assert has_access(t, 'read', user=observer)()
        assert has_access(t, 'read', user=anon)()
开发者ID:Bitergia,项目名称:allura,代码行数:56,代码来源:test_ticket_model.py

示例3: test_ticket_move_with_users_not_in_project

    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)
开发者ID:johnsca,项目名称:incubator-allura,代码行数:32,代码来源:test_ticket_model.py

示例4: test_ticket_move_with_different_custom_fields

    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)
开发者ID:johnsca,项目名称:incubator-allura,代码行数:27,代码来源:test_ticket_model.py

示例5: test_ticket_move

    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)
开发者ID:johnsca,项目名称:incubator-allura,代码行数:32,代码来源:test_ticket_model.py

示例6: test_json_parents

 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
开发者ID:joequant,项目名称:allura,代码行数:7,代码来源:test_ticket_model.py

示例7: test_paged_query_or_search

    def test_paged_query_or_search(self, query, search, tsearch):
        app_cfg, user = mock.Mock(), mock.Mock()
        mongo_query = 'mongo query'
        solr_query = 'solr query'
        kw = {'kw1': 'test1', 'kw2': 'test2'}
        filter = None
        Ticket.paged_query_or_search(app_cfg, user, mongo_query, solr_query, filter, **kw)
        query.assert_called_once_with(app_cfg, user, mongo_query, sort=None, limit=None, page=0, **kw)
        assert_equal(tsearch.query_filter_choices.call_count, 1)
        assert_equal(tsearch.query_filter_choices.call_args[0][0], 'solr query')
        assert_equal(search.call_count, 0)
        query.reset_mock(), search.reset_mock(), tsearch.reset_mock()

        filter = {'status': 'unread'}
        Ticket.paged_query_or_search(app_cfg, user, mongo_query, solr_query, filter, **kw)
        search.assert_called_once_with(app_cfg, user, solr_query, filter=filter, sort=None, limit=None, page=0, **kw)
        assert_equal(query.call_count, 0)
        assert_equal(tsearch.query_filter_choices.call_count, 0)
开发者ID:joequant,项目名称:allura,代码行数:18,代码来源:test_ticket_model.py

示例8: test_attach_with_resettable_stream

 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')
开发者ID:jekatgithub,项目名称:incubator-allura,代码行数:15,代码来源:test_ticket_model.py

示例9: query_tickets

    def query_tickets(self, page, limit):
        from forgetracker.model import Ticket

        q = ' OR '.join(['assigned_to:' + str(self.user['username']), 'reported_by:' + str(self.user['username'])])
        sort = 'mod_date_dt desc'
        result = Ticket.paged_search(None, self.user, q, limit=limit, page=page, sort=sort)

        tickets = [
            dict(
                ticket_num=ticket['ticket_num'],
                url=ticket.url(),
                summary=ticket['summary'],
                mod_date=ticket['mod_date'],
                reported_by=ticket['reported_by'],
                assigned_to_id=ticket['assigned_to_id'],
                assigned_to=ticket['assigned_to'],
                status=ticket['status'])
            for ticket in result.get('tickets')
        ]
        return dict(tickets=tickets, count=result.get('count'), solr_error=result.get('solr_error'))
开发者ID:apache,项目名称:allura,代码行数:20,代码来源:dashboard_main.py

示例10: test_has_activity_access

 def test_has_activity_access(self):
     t = Ticket(summary='ticket', ticket_num=666)
     assert_true(t.has_activity_access('read', c.user, 'activity'))
     t.deleted = True
     assert_false(t.has_activity_access('read', c.user, 'activity'))
开发者ID:joequant,项目名称:allura,代码行数:5,代码来源:test_ticket_model.py

示例11: test_private_ticket

    def test_private_ticket(self):
        from allura.model import ProjectRole
        from allura.model import ACE, DENY_ALL
        from allura.lib.security import Credentials, has_access
        from allura.websetup import bootstrap

        admin = c.user
        creator = bootstrap.create_user('Not a Project Admin')
        developer = bootstrap.create_user('Project Developer')
        observer = bootstrap.create_user('Random Non-Project User')
        anon = User(_id=None, username='*anonymous',
                    display_name='Anonymous')
        t = Ticket(summary='my ticket', ticket_num=3,
                   reported_by_id=creator._id)

        assert creator == t.reported_by
        role_admin = ProjectRole.by_name('Admin')._id
        role_developer = ProjectRole.by_name('Developer')._id
        role_creator = ProjectRole.by_user(t.reported_by, upsert=True)._id
        ProjectRole.by_user(
            developer, upsert=True).roles.append(role_developer)
        ThreadLocalORMSession.flush_all()
        cred = Credentials.get().clear()

        t.private = True
        assert_equal(t.acl, [
            ACE.allow(role_developer, 'save_searches'),
            ACE.allow(role_developer, 'read'),
            ACE.allow(role_developer, 'create'),
            ACE.allow(role_developer, 'update'),
            ACE.allow(role_developer, 'unmoderated_post'),
            ACE.allow(role_developer, 'post'),
            ACE.allow(role_developer, 'moderate'),
            ACE.allow(role_developer, 'delete'),
            ACE.allow(role_creator, 'read'),
            ACE.allow(role_creator, 'post'),
            ACE.allow(role_creator, 'create'),
            ACE.allow(role_creator, 'unmoderated_post'),
            DENY_ALL])
        assert has_access(t, 'read', user=admin)()
        assert has_access(t, 'create', user=admin)()
        assert has_access(t, 'update', user=admin)()
        assert has_access(t, 'read', user=creator)()
        assert has_access(t, 'post', user=creator)()
        assert has_access(t, 'unmoderated_post', user=creator)()
        assert has_access(t, 'create', user=creator)()
        assert not has_access(t, 'update', user=creator)()
        assert has_access(t, 'read', user=developer)()
        assert has_access(t, 'create', user=developer)()
        assert has_access(t, 'update', user=developer)()
        assert not has_access(t, 'read', user=observer)()
        assert not has_access(t, 'create', user=observer)()
        assert not has_access(t, 'update', user=observer)()
        assert not has_access(t, 'read', user=anon)()
        assert not has_access(t, 'create', user=anon)()
        assert not has_access(t, 'update', user=anon)()

        t.private = False
        assert t.acl == []
        assert has_access(t, 'read', user=admin)()
        assert has_access(t, 'create', user=admin)()
        assert has_access(t, 'update', user=admin)()
        assert has_access(t, 'read', user=developer)()
        assert has_access(t, 'create', user=developer)()
        assert has_access(t, 'update', user=developer)()
        assert has_access(t, 'read', user=creator)()
        assert has_access(t, 'unmoderated_post', user=creator)()
        assert has_access(t, 'create', user=creator)()
        assert not has_access(t, 'update', user=creator)()
        assert has_access(t, 'read', user=observer)()
        assert has_access(t, 'read', user=anon)()
开发者ID:joequant,项目名称:allura,代码行数:71,代码来源:test_ticket_model.py


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