• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python ormsession.ThreadLocalORMSession类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_interactive

 def test_interactive(self, Request, Server):
     M.OAuthConsumerToken.consumer = mock.Mock()
     user = M.User.by_username('test-admin')
     consumer_token = M.OAuthConsumerToken(
         api_key='api_key',
         user_id=user._id,
         description='ctok_desc',
     )
     ThreadLocalORMSession.flush_all()
     req = Request.from_request.return_value = {
         'oauth_consumer_key': 'api_key',
         'oauth_callback': 'http://my.domain.com/callback',
     }
     r = self.app.post('/rest/oauth/request_token', params={})
     rtok = parse_qs(r.body)['oauth_token'][0]
     r = self.app.post('/rest/oauth/authorize',
                       params={'oauth_token': rtok})
     r = r.forms[0].submit('yes')
     assert r.location.startswith('http://my.domain.com/callback')
     pin = parse_qs(urlparse(r.location).query)['oauth_verifier'][0]
     #pin = r.html.find(text=re.compile('^PIN: ')).split()[1]
     req = Request.from_request.return_value = {
         'oauth_consumer_key': 'api_key',
         'oauth_token': rtok,
         'oauth_verifier': pin,
     }
     r = self.app.get('/rest/oauth/access_token')
     atok = parse_qs(r.body)
     assert_equal(len(atok['oauth_token']), 1)
     assert_equal(len(atok['oauth_token_secret']), 1)
开发者ID:apache,项目名称:incubator-allura,代码行数:30,代码来源:test_auth.py


示例2: test_milestone_rename

 def test_milestone_rename(self):
     self.new_ticket(summary='test milestone rename')
     self.app.post('/bugs/1/update_ticket',{
         'summary':'test milestone rename',
         'description':'',
         'status':'',
         '_milestone':'1.0',
         'assigned_to':'',
         'labels':'',
         'labels_old':'',
         'comment': ''
     })
     ThreadLocalORMSession.flush_all()
     M.MonQTask.run_ready()
     ThreadLocalORMSession.flush_all()
     ticket_view = self.app.get('/p/test/bugs/1/')
     assert 'Milestone' in ticket_view
     assert '1.0' in ticket_view
     assert 'zzzé' not in ticket_view
     r = self.app.post('/bugs/update_milestones',{
         'field_name':'_milestone',
         'milestones-0.old_name':'1.0',
         'milestones-0.new_name':'zzzé',
         'milestones-0.description':'',
         'milestones-0.complete':'Open',
         'milestones-0.due_date':''
     })
     ticket_view = self.app.get('/p/test/bugs/1/')
     assert '1.0' not in ticket_view
     assert 'zzzé' in ticket_view
开发者ID:Bitergia,项目名称:allura,代码行数:30,代码来源:test_root.py


示例3: test_prefs

 def test_prefs(self):
     r = self.app.get('/auth/preferences/', extra_environ=dict(username='test-admin'))
     assert '[email protected]' not in r
     r = self.app.post('/auth/preferences/update', params={
              'preferences.display_name':'Test Admin',
              'new_addr.addr':'[email protected]',
              'new_addr.claim':'Claim Address',
              'primary_addr':'[email protected]',
              'preferences.email_format':'plain'},
             extra_environ=dict(username='test-admin'))
     r = self.app.get('/auth/preferences/')
     assert '[email protected]' in r
     r = self.app.post('/auth/preferences/update', params={
              'preferences.display_name':'Test Admin',
              'addr-1.ord':'1',
              'addr-2.ord':'1',
              'addr-2.delete':'on',
              'new_addr.addr':'',
              'primary_addr':'[email protected]',
              'preferences.email_format':'plain'},
             extra_environ=dict(username='test-admin'))
     r = self.app.get('/auth/preferences/')
     assert '[email protected]' not in r
     ea = M.EmailAddress.query.get(_id='[email protected]')
     ea.confirmed = True
     ThreadLocalORMSession.flush_all()
     r = self.app.post('/auth/preferences/update', params={
              'preferences.display_name':'Test Admin',
              'new_addr.addr':'[email protected]',
              'new_addr.claim':'Claim Address',
              'primary_addr':'[email protected]',
              'preferences.email_format':'plain'},
             extra_environ=dict(username='test-admin'))
开发者ID:johnsca,项目名称:incubator-allura,代码行数:33,代码来源:test_auth.py


示例4: test_that_label_counts_are_local_to_tool

    def test_that_label_counts_are_local_to_tool(self):
        """Test that label queries return only artifacts from the specified
        tool.
        """
        # create a ticket in two different tools, with the same label
        from allura.tests import decorators as td

        @td.with_tool('test', 'Tickets', 'bugs', username='test-user')
        def _test_ticket():
            return Ticket(ticket_num=1, summary="ticket1", labels=["mylabel"])

        @td.with_tool('test', 'Tickets', 'bugs2', username='test-user')
        def _test_ticket2():
            return Ticket(ticket_num=2, summary="ticket2", labels=["mylabel"])

        # create and save the tickets
        t1 = _test_ticket()
        t2 = _test_ticket2()
        ThreadLocalORMSession.flush_all()

        # test label query results
        label_count1 = t1.artifacts_labeled_with(
            "mylabel", t1.app_config).count()
        label_count2 = t2.artifacts_labeled_with(
            "mylabel", t2.app_config).count()
        assert 1 == label_count1 == label_count2
开发者ID:joequant,项目名称:allura,代码行数:26,代码来源:test_ticket_model.py


示例5: test_disable_user

 def test_disable_user(self):
     user = Mock(disabled=False, __ming__=Mock(), is_anonymous=lambda: False, _id=ObjectId())
     c.user = Mock(username='test-admin')
     with audits('Account disabled', user=True, actor='test-admin'):
         self.provider.disable_user(user)
         ThreadLocalORMSession.flush_all()
     assert_equal(user.disabled, True)
开发者ID:dastanforever,项目名称:allura,代码行数:7,代码来源:test_plugin.py


示例6: 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


示例7: make_artifact

    def make_artifact(self, ticket_dict):
        remapped = {}
        for f, v in ticket_dict.iteritems():
            transform = self.FIELD_MAP.get(f, ())
            if transform is None:
                continue
            elif transform is True:
                remapped[f] = v
            elif callable(transform):
                transform(remapped, f, v)
            elif transform is ():
                self.custom(remapped, f, v)
            else:
                new_f, conv = transform
                remapped[new_f] = conv(v)

        ticket_num = ticket_dict['id']
        existing_ticket = TM.Ticket.query.get(app_config_id=c.app.config._id,
                                          ticket_num=ticket_num)
        if existing_ticket:
            ticket_num = c.app.globals.next_ticket_num()
            self.warnings.append('Ticket #%s: Ticket with this id already exists, using next available id: %s' % (ticket_dict['id'], ticket_num))
        else:
            if c.app.globals.last_ticket_num < ticket_num:
                c.app.globals.last_ticket_num = ticket_num
                ThreadLocalORMSession.flush_all()

        ticket = TM.Ticket(
            app_config_id=c.app.config._id,
            custom_fields=dict(),
            ticket_num=ticket_num,
            import_id=c.api_token.api_key)
        ticket.update(remapped)
        return ticket
开发者ID:Bitergia,项目名称:allura,代码行数:34,代码来源:import_support.py


示例8: private_project

    def private_project(self):
        '''
        Returns the personal user-project for the user
        '''
        if self.disabled or self.pending:
            return None

        from allura import model as M

        n = self.neighborhood
        auth_provider = plugin.AuthenticationProvider.get(request)
        project_shortname = auth_provider.user_project_shortname(self)
        p = M.Project.query.get(
            shortname=project_shortname, neighborhood_id=n._id)
        if p and p.deleted:
            # really delete it, since registering a new project would conflict
            # with the "deleted" one
            log.info(
                'completely deleting user project (was already flagged as deleted) %s',
                project_shortname)
            p.delete()
            ThreadLocalORMSession.flush_all()
            p = None
        if not p and not self.is_anonymous():
            # create user-project on demand if it is missing
            p = n.register_project(
                project_shortname, user=self, user_project=True)
        return p
开发者ID:abhinavthomas,项目名称:allura,代码行数:28,代码来源:auth.py


示例9: 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


示例10: test_artifactlink

def test_artifactlink():
    pg = WM.Page(title='TestPage2')
    q = M.Shortlink.query.find(dict(
            project_id=c.project._id,
            app_config_id=c.app.config._id,
            link=pg.shorthand_id()))
    assert q.count() == 0
    ThreadLocalORMSession.flush_all()
    M.MonQTask.run_ready()
    ThreadLocalORMSession.flush_all()
    assert q.count() == 1
    assert M.Shortlink.lookup('[TestPage2]')
    assert M.Shortlink.lookup('[wiki:TestPage2]')
    assert M.Shortlink.lookup('[test:wiki:TestPage2]')
    assert not M.Shortlink.lookup('[test:wiki:TestPage2:foo]')
    assert not M.Shortlink.lookup('[Wiki:TestPage2]')
    assert not M.Shortlink.lookup('[TestPage2_no_such_page]')
    c.project.uninstall_app('wiki')
    ThreadLocalORMSession.flush_all()
    assert not M.Shortlink.lookup('[wiki:TestPage2]')
    pg.delete()
    ThreadLocalORMSession.flush_all()
    M.MonQTask.run_ready()
    ThreadLocalORMSession.flush_all()
    assert q.count() == 0
开发者ID:jekatgithub,项目名称:incubator-allura,代码行数:25,代码来源:test_artifact.py


示例11: test_user_project_does_not_create_on_demand_for_openid_user

def test_user_project_does_not_create_on_demand_for_openid_user():
    u = M.User.register({'username': ''}, make_project=False)
    ThreadLocalORMSession.flush_all()
    assert not u.private_project()
    assert not M.Project.query.get(shortname='u/')
    assert not M.Project.query.get(shortname='u/anonymous')
    assert not M.Project.query.get(shortname='u/*anonymous')
开发者ID:pombredanne,项目名称:incubator-allura,代码行数:7,代码来源:test_auth.py


示例12: test_user

def test_user():
    assert c.user.url() .endswith('/u/test-admin/')
    assert c.user.script_name .endswith('/u/test-admin/')
    assert_equal(set(p.shortname for p in c.user.my_projects()),
                 set(['test', 'test2', 'u/test-admin', 'adobe-1', '--init--']))
    # delete one of the projects and make sure it won't appear in my_projects()
    p = M.Project.query.get(shortname='test2')
    p.deleted = True
    ThreadLocalORMSession.flush_all()
    assert_equal(set(p.shortname for p in c.user.my_projects()),
                 set(['test', 'u/test-admin', 'adobe-1', '--init--']))
    u = M.User.register(dict(
        username='nosetest-user'))
    ThreadLocalORMSession.flush_all()
    assert_equal(u.private_project().shortname, 'u/nosetest-user')
    roles = g.credentials.user_roles(
        u._id, project_id=u.private_project().root_project._id)
    assert len(roles) == 3, roles
    u.set_password('foo')
    provider = plugin.LocalAuthenticationProvider(Request.blank('/'))
    assert provider._validate_password(u, 'foo')
    assert not provider._validate_password(u, 'foobar')
    u.set_password('foobar')
    assert provider._validate_password(u, 'foobar')
    assert not provider._validate_password(u, 'foo')
开发者ID:apache,项目名称:allura,代码行数:25,代码来源:test_auth.py


示例13: install

 def install(self, project):
     '''Create repo object for this tool'''
     super(ForgeGitApp, self).install(project)
     repo = GM.Repository(
         name=self.config.options.mount_point + '.git',
         tool='git',
         status='initializing',
         fs_path=self.config.options.get('fs_path'))
     ThreadLocalORMSession.flush_all()
     cloned_from_project_id = self.config.options.get('cloned_from_project_id')
     cloned_from_repo_id = self.config.options.get('cloned_from_repo_id')
     init_from_url = self.config.options.get('init_from_url')
     init_from_path = self.config.options.get('init_from_path')
     if cloned_from_project_id is not None:
         cloned_from = GM.Repository.query.get(_id=cloned_from_repo_id)
         repo.default_branch_name = cloned_from.default_branch_name
         repo.additional_viewable_extensions = cloned_from.additional_viewable_extensions
         allura.tasks.repo_tasks.clone.post(
             cloned_from_path=cloned_from.full_fs_path,
             cloned_from_name=cloned_from.app.config.script_name(),
             cloned_from_url=cloned_from.full_fs_path)
     elif init_from_url or init_from_path:
         allura.tasks.repo_tasks.clone.post(
             cloned_from_path=init_from_path,
             cloned_from_name=None,
             cloned_from_url=init_from_url)
     else:
         allura.tasks.repo_tasks.init.post()
开发者ID:apache,项目名称:allura,代码行数:28,代码来源:git_main.py


示例14: install

 def install(self, project):
     '''Create repo object for this tool'''
     super(ForgeHgApp, self).install(project)
     HM.Repository(
         name=self.config.options.mount_point,
         tool='hg',
         status='initializing')
     ThreadLocalORMSession.flush_all()
     cloned_from_project_id = self.config.options.get('cloned_from_project_id')
     cloned_from_repo_id = self.config.options.get('cloned_from_repo_id')
     init_from_url = self.config.options.get('init_from_url')
     init_from_path = self.config.options.get('init_from_path')
     if cloned_from_project_id is not None:
         cloned_from = HM.Repository.query.get(_id=cloned_from_repo_id)
         allura.tasks.repo_tasks.clone.post(
             cloned_from_path=cloned_from.full_fs_path,
             cloned_from_name=cloned_from.app.config.script_name(),
             cloned_from_url=cloned_from.full_fs_path,
             copy_hooks=self.config.options.get('copy_hooks', False))
     elif init_from_url or init_from_path:
         allura.tasks.repo_tasks.clone.post(
             cloned_from_path=init_from_path,
             cloned_from_name=None,
             cloned_from_url=init_from_url,
             copy_hooks=self.config.options.get('copy_hooks', False))
     else:
         allura.tasks.repo_tasks.init.post()
开发者ID:Bitergia,项目名称:allura,代码行数:27,代码来源:hg_main.py


示例15: install

 def install(self, project):
     """Create repo object for this tool"""
     super(ForgeGitApp, self).install(project)
     repo = GM.Repository(name=self.config.options.mount_point + ".git", tool="git", status="initializing")
     ThreadLocalORMSession.flush_all()
     cloned_from_project_id = self.config.options.get("cloned_from_project_id")
     cloned_from_repo_id = self.config.options.get("cloned_from_repo_id")
     init_from_url = self.config.options.get("init_from_url")
     init_from_path = self.config.options.get("init_from_path")
     if cloned_from_project_id is not None:
         cloned_from = GM.Repository.query.get(_id=cloned_from_repo_id)
         allura.tasks.repo_tasks.clone.post(
             cloned_from_path=cloned_from.full_fs_path,
             cloned_from_name=cloned_from.app.config.script_name(),
             cloned_from_url=cloned_from.full_fs_path,
             copy_hooks=self.config.options.get("copy_hooks", False),
         )
     elif init_from_url or init_from_path:
         allura.tasks.repo_tasks.clone.post(
             cloned_from_path=init_from_path,
             cloned_from_name=None,
             cloned_from_url=init_from_url,
             copy_hooks=self.config.options.get("copy_hooks", False),
         )
     else:
         allura.tasks.repo_tasks.init.post()
开发者ID:Bitergia,项目名称:allura,代码行数:26,代码来源:git_main.py


示例16: main

def main():
    test = sys.argv[-1] == 'test'
    num_projects_examined = 0
    log.info('Examining subroles in all non-user projects.')
    n_users = M.Neighborhood.query.get(name='Users')
    project_filter = dict(neighborhood_id={'$ne': n_users._id})
    for some_projects in utils.chunked_find(M.Project, project_filter):
        for project in some_projects:
            project_name = '%s.%s' % (
                project.neighborhood.name, project.shortname)
            project_roles = {}
            for parent, child in [('Admin', 'Developer'), ('Developer', 'Member')]:
                parent_role = M.ProjectRole.by_name(parent, project=project)
                child_role = M.ProjectRole.by_name(child, project=project)
                project_roles[parent] = parent_role
                project_roles[child] = child_role
                if not (parent_role and child_role):
                    break
                if len(parent_role.roles) != 1 or parent_role.roles[0] != child_role._id:
                    if test:
                        log.info('Would reset %s subroles for project "%s".' %
                                 (parent, project_name))
                        log.info('- Existing %s subrole(s): %s' %
                                 (parent, parent_role.roles))
                    else:
                        log.info('Resetting %s subroles for project "%s".' %
                                 (parent, project_name))
                        parent_role.roles = [child_role._id]
                        ThreadLocalORMSession.flush_all()
            if not (project_roles['Admin'] and project_roles['Developer']
                    and project_roles['Member']):
                log.info(
                    'Skipping "%s": missing Admin, Developer, or Member roles' %
                    project_name)
                continue
            for user in project.users():
                pr = user.project_role(project=project)
                if not pr.roles:
                    continue
                for parent, children in [('Admin', ('Developer', 'Member')),
                                         ('Developer', ('Member',))]:
                    if project_roles[parent]._id not in pr.roles:
                        continue
                    for role_name in children:
                        extra_role = project_roles[role_name]
                        if extra_role._id in pr.roles:
                            if test:
                                log.info('Would remove %s role from user "%s" in project "%s" (already has %s role).'
                                         % (role_name, user.username, project_name, parent))
                                pr.roles.remove(extra_role._id)
                            else:
                                log.info('Removing %s role from user "%s" in project "%s" (already has %s role).'
                                         % (role_name, user.username, project_name, parent))
                                pr.roles.remove(extra_role._id)
                                ThreadLocalORMSession.flush_all()
            num_projects_examined += 1
            session(project).clear()

        log.info('%s projects examined.' % num_projects_examined)
开发者ID:AsylumCorp,项目名称:incubator-allura,代码行数:59,代码来源:011-fix-subroles.py


示例17: command

    def command(self):
        self.basic_setup()
        self.hostname = socket.gethostname()
        self.taskd_status_log = self.args[1]
        self.stuck_pids = []
        self.error_tasks = []
        self.suspicious_tasks = []

        taskd_pids = self._taskd_pids()
        base.log.info('Taskd processes on %s: %s' % (self.hostname, taskd_pids))

        # find stuck taskd processes
        base.log.info('Seeking for stuck taskd processes')
        for pid in taskd_pids:
            base.log.info('...sending USR1 to %s and watching status log' % (pid))
            status = self._check_taskd_status(int(pid))
            if status != 'OK':
                base.log.info('...taskd pid %s has stuck' % pid)
                self.stuck_pids.append(pid)
                if self.options.kill:
                    base.log.info('...-k is set. Killing %s' % pid)
                    self._kill_stuck_taskd(pid)
            else:
                base.log.info('...%s' % status)

        # find 'forsaken' tasks
        base.log.info('Seeking for forsaken busy tasks')
        tasks = [t for t in self._busy_tasks()
                 if t not in self.error_tasks]  # skip seen tasks
        base.log.info('Found %s busy tasks on %s' % (len(tasks), self.hostname))
        for task in tasks:
            base.log.info('Verifying task %s' % task)
            pid = task.process.split()[-1]
            if pid not in taskd_pids:
                # 'forsaken' task
                base.log.info('Task is forsaken '
                    '(can\'t find taskd with given pid). '
                    'Setting state to \'error\'')
                task.state = 'error'
                task.result = 'Can\'t find taskd with given pid'
                self.error_tasks.append(task)
            else:
                # check if taskd with given pid really processing this task now:
                base.log.info('Checking that taskd pid %s is really processing task %s' % (pid, task._id))
                status = self._check_task(pid, task)
                if status != 'OK':
                    # maybe task moved quickly and now is complete
                    # so we need to check such tasks later
                    # and mark incomplete ones as 'error'
                    self.suspicious_tasks.append(task)
                    base.log.info('...NO. Adding task to suspisious list')
                else:
                    base.log.info('...OK')

        # check suspicious task and mark incomplete as error
        base.log.info('Checking suspicious list for incomplete tasks')
        self._check_suspicious_tasks()
        ThreadLocalORMSession.flush_all()
        self.print_summary()
开发者ID:jekatgithub,项目名称:incubator-allura,代码行数:59,代码来源:taskd_cleanup.py


示例18: test_pull_rss_feeds

def test_pull_rss_feeds(parsefeed):
    html_content = (
        "<p>1. foo</p>\n"
        "\n"
        "<p>\n"
        "#foo bar <a href='baz'>baz</a>\n"
        "foo bar\n"
        "</p>\n"
        "\n"
        "<p>#foo bar <a href='baz'>\n"
        "baz\n"
        "</a></p>\n"
    )

    rendered_html_content = "\n".join([
        r"1\. foo",
        "",
        r"\#foo bar [baz](baz) foo bar ",
        "",
        r"\#foo bar [ baz ](baz)",
        " [link](http://example.com/)",
    ])

    parsefeed.return_value = _mock_feed(
        dict(title='Test', subtitle='test', summary='This is a test'),
        dict(content_type='text/plain', content='Test feed'),
        dict(content_type='text/html', content=html_content),
        dict(summary_detail=dict(type='text/html', value=html_content)),
    )

    base_app = M.AppConfig.query.find().all()[0]
    tmp_app = M.AppConfig(
        tool_name=u'Blog', discussion_id=base_app.discussion_id,
        project_id=base_app.project_id,
        options={u'ordinal': 0, u'show_right_bar': True,
                 u'project_name': base_app.project.name,
                 u'mount_point': u'blog',
                 u'mount_label': u'Blog'})
    new_external_feeds = ['http://example.com/news/feed/']
    BM.Globals(app_config_id=tmp_app._id, external_feeds=new_external_feeds)
    ThreadLocalORMSession.flush_all()

    from forgeblog.command import rssfeeds
    cmd = rssfeeds.RssFeedsCommand('pull-rss-feeds')
    cmd.run([test_config, '-a', tmp_app._id])
    cmd.command()
    parsefeed.assert_called_with('http://example.com/news/feed/')
    posts = BM.BlogPost.query.find(
        {'app_config_id': tmp_app._id}).sort('timestamp', 1)
    assert_equal(posts.count(), 4)
    posts = posts.all()
    assert_equal(posts[0].title, 'Test')
    assert_equal(posts[0].text, 'This is a test [link](http://example.com/)')
    assert_equal(posts[1].title, 'Default Title 2')
    assert_equal(posts[1].text, 'Test feed [link](http://example.com/)')
    assert_equal(posts[2].title, 'Default Title 3')
    assert_equal(posts[2].text, rendered_html_content)
    assert_equal(posts[3].title, 'Default Title 4')
    assert_equal(posts[3].text, rendered_html_content)
开发者ID:apache,项目名称:allura,代码行数:59,代码来源:test_commands.py


示例19: main

def main():
    broken_posts = BM.BlogPost.query.find(dict(neighborhood_id=None)).all()
    for post in broken_posts:
        c.project = post.app.project
        c.app = post.app
        post.neighborhood_id = post.app.project.neighborhood_id
        ThreadLocalORMSession.flush_all()
    ThreadLocalORMSession.close_all()
开发者ID:AsylumCorp,项目名称:incubator-allura,代码行数:8,代码来源:015-add-neighborhood_id-to-blog-posts.py


示例20: load

 def load(self):
     artifact_orm_session._get().skip_mod_date = True
     self.load_pages()
     self.project.notifications_disabled = False
     artifact_orm_session._get().skip_mod_date = False
     ThreadLocalORMSession.flush_all()
     ThreadLocalORMSession.close_all()
     allura_base.log.info('Loading wiki done')
开发者ID:Bitergia,项目名称:allura,代码行数:8,代码来源:loaders.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python fluidsynth.init函数代码示例发布时间:2022-05-27
下一篇:
Python orm.ThreadLocalORMSession类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap