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

Python tests.project函数代码示例

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

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



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

示例1: test_contextual_feeds

    def test_contextual_feeds(self):
        """Test that team/project/user Atom feeds appear as <link> tags."""

        with self.app.app_context():
            user(email='[email protected]', save=True)
            u = user(username='buffy', email="[email protected]",
                     name='Buffy Summers', slug='buffy', save=True)
            team(name='Scooby Gang', slug='scoobies', users=[u], save=True)
            project(name='Kill The Master', slug='master', save=True)

        authenticate(self.client, u)

        site_url = self.app.config.get('SITE_URL')

        rv = self.client.get('/')
        assert ('<link rel="alternate" type="application/atom+xml" '
                'href="%s/statuses.xml"') % site_url in rv.data
        assert ('<link rel="alternate" type="application/atom+xml" '
                'href="%s/project/') % site_url not in rv.data

        rv = self.client.get('/team/scoobies')
        assert ('<link rel="alternate" type="application/atom+xml" '
                'href="%s/team/') % site_url in rv.data

        rv = self.client.get('/project/master')
        assert ('<link rel="alternate" type="application/atom+xml" '
                'href="%s/project/') % site_url in rv.data

        rv = self.client.get('/user/buffy')
        assert ('<link rel="alternate" type="application/atom+xml" '
                'href="%s/user/') % site_url in rv.data
开发者ID:robhudson,项目名称:standup,代码行数:31,代码来源:test_status.py


示例2: test_timeline_filters_project

    def test_timeline_filters_project(self):
        """Test the timeline only shows the passed in project."""
        with self.app.app_context():
            u = user(save=True)
            p = project(save=True)
            status(user=u, project=p, save=True)
            p2 = project(name="Test Project 2", slug="test-project-2", save=True)
            status(user=u, project=p2, save=True)

        response = self.client.get(self._url())
        data = json.loads(response.data)
        eq_(len(data), 1)
        eq_(data[0]["project"], p.dictify())
开发者ID:safwanrahman,项目名称:standup,代码行数:13,代码来源:test_api2.py


示例3: test_timeline_count

    def test_timeline_count(self):
        """Test the count parameter of home_timeline"""
        self.app.config['API2_TIMELINE_MAX_RESULTS'] = 50
        with self.app.app_context():
            u = user(save=True, team={})
            p = project(save=True)
            for i in range(60):
                status(project=p, user=u, save=True)

        response = self.client.get(self._url())
        data = json.loads(response.data)
        eq_(len(data), 20)

        # Test with an acceptable count
        response = self.client.get(self._url(dict(count=50)))
        data = json.loads(response.data)
        eq_(len(data), 50)

        # Test with a count that is too large
        response = self.client.get(self._url(dict(count=60)))
        eq_(response.status_code, 400)

        # Test with a count that is too small
        response = self.client.get(self._url(dict(count=0)))
        eq_(response.status_code, 400)

        # Test with an invalid count
        response = self.client.get(self._url(dict(count='a')))
        eq_(response.status_code, 400)
开发者ID:chinna1986,项目名称:standup,代码行数:29,代码来源:test_api2.py


示例4: test_timeline_since_id

    def test_timeline_since_id(self):
        """Test the since_id parameter of home_timeline"""
        with self.app.app_context():
            u = user(save=True, team={})
            p = project(save=True)
            for i in range(30):
                status(project=p, user=u, save=True)

        response = self.client.get(self._url(dict(since_id=10, count=20)))
        data = json.loads(response.data)
        eq_(data[19]['id'], 11)

        response = self.client.get(self._url(dict(since_id=10, count=10)))
        data = json.loads(response.data)
        eq_(data[9]['id'], 21)

        response = self.client.get(self._url(dict(since_id=10, count=30)))
        data = json.loads(response.data)
        eq_(len(data), 20)
        eq_(data[19]['id'], 11)

        response = self.client.get(self._url(dict(since_id=0)))
        eq_(response.status_code, 400)

        response = self.client.get(self._url(dict(since_id='a')))
        eq_(response.status_code, 400)
开发者ID:chinna1986,项目名称:standup,代码行数:26,代码来源:test_api2.py


示例5: test_timeline

 def test_timeline(self):
     """Test the home_timeline endpoint"""
     with self.app.app_context():
         u = user(save=True, team={})
         p = project(save=True)
         status(user=u, project=p, save=True)
     response = self.client.get(self._url())
     eq_(response.status_code, 200)
     eq_(response.content_type, 'application/json')
开发者ID:chinna1986,项目名称:standup,代码行数:9,代码来源:test_api2.py


示例6: test_project_view

    def test_project_view(self):
        """Make sure the project view works like it's supposed to."""
        with self.app.app_context():
            p = project(save=True)

        response = self.client.get('/project/%s' % p.slug)
        eq_(response.status_code, 200)

        response = self.client.get('/project/not-a-real-project')
        eq_(response.status_code, 404)
开发者ID:robhudson,项目名称:standup,代码行数:10,代码来源:test_status.py


示例7: test_paginate

    def test_paginate(self):
        """Test the paginate helper function."""
        db = get_session(self.app)

        statuses = []
        with self.app.app_context():
            p = project(save=True)
            u = user(save=True)

            # Create 100 statuses
            for i in range(30):
                statuses.append(status(project=p, user=u,
                                       created=datetime(2012, 5, 25),
                                       save=True))

            for i in range(30):
                statuses.append(status(project=p, user=u,
                                       created=datetime(2012, 6, 25),
                                       save=True))

            for i in range(40):
                statuses.append(status(project=p, user=u,
                                       created=datetime(2012, 7, 25),
                                       save=True))

        s = db.query(Status).order_by(Status.id)

        # Test simple pagination
        page = paginate(s, page=1)

        eq_(page.pages, 5)

        eq_(page.has_prev, False)
        eq_(page.has_next, True)

        page = paginate(s, page=3)
        eq_(page.has_prev, True)
        eq_(page.has_next, True)

        page = paginate(s, page=5)
        eq_(page.has_prev, True)
        eq_(page.has_next, False)

        # Test date filtered pagination
        page = paginate(s, page=1, startdate=datetime(2012, 5, 28))
        eq_(page.pages, 4)

        page = paginate(s, page=1, startdate=datetime(2012, 5, 28),
                        enddate=datetime(2012, 6, 28))
        eq_(page.pages, 2)

        page = paginate(s, page=1, enddate=datetime(2012, 6, 28))
        eq_(page.pages, 3)
开发者ID:robhudson,项目名称:standup,代码行数:53,代码来源:test_status.py


示例8: test_status_with_project

    def test_status_with_project(self):
        """Test posting a status with a project."""
        with self.app.app_context():
            u = user(email='[email protected]', save=True)
            p = project(name='blackhole', slug='blackhole', save=True)
            data = {'message': 'r1cky rocks!', 'project': p.id}

        authenticate(self.client, u)

        rv = self.client.post('/statusize/', follow_redirects=True,
                              data=data)
        eq_(rv.status_code, 200)
开发者ID:robhudson,项目名称:standup,代码行数:12,代码来源:test_status.py


示例9: test_status_replies

    def test_status_replies(self):
        """Test the loading of replies for a status."""
        with self.app.app_context():
            p = project(save=True)
            u = user(save=True)
            s = status(project=p, user=u, save=True)

            for i in range(30):
                status(project=p, user=u, reply_to=s, save=True)

            page = s.replies()

        eq_(page.pages, 2)
开发者ID:robhudson,项目名称:standup,代码行数:13,代码来源:test_status.py


示例10: test_timeline_trim_project

    def test_timeline_trim_project(self):
        """Test the trim_project parameter of home_timeline"""
        with self.app.app_context():
            p = project(save=True)
            status(project=p, save=True)

        response = self.client.get(self._url())
        data = json.loads(response.data)
        eq_(data[0]["project"], p.dictify())

        response = self.client.get(self._url(dict(trim_project=1)))
        data = json.loads(response.data)
        eq_(data[0]["project"], p.id)
开发者ID:robhudson,项目名称:standup,代码行数:13,代码来源:test_api2.py


示例11: test_timeline_trim_user

    def test_timeline_trim_user(self):
        """Test the trim_user parameter of home_timeline"""
        with self.app.app_context():
            u = user(save=True, team={})
            p = project(save=True)
            status(user=u, project=p, save=True)

        response = self.client.get(self._url())
        data = json.loads(response.data)
        eq_(data[0]['user'], u.dictify())

        response = self.client.get(self._url(dict(trim_user=1)))
        data = json.loads(response.data)
        eq_(data[0]['user'], u.id)
开发者ID:chinna1986,项目名称:standup,代码行数:14,代码来源:test_api2.py


示例12: test_timeline_filters_team

    def test_timeline_filters_team(self):
        """Test the timeline only shows the passed in team."""
        with self.app.app_context():
            u = user(save=True, team={})
            u2 = user(
                username="janedoe", email="[email protected]", slug="janedoe", save=True, team={"name": "XXX", "slug": "xxx"}
            )
            p = project(save=True)
            status(user=u, project=p, save=True)
            status(user=u2, project=p, save=True)

        response = self.client.get(self._url(dict(team_id=u.teams[0].id)))
        data = json.loads(response.data)
        eq_(len(data), 1)
        eq_(data[0]["user"], u.dictify())
开发者ID:safwanrahman,项目名称:standup,代码行数:15,代码来源:test_api2.py


示例13: test_timeline_filters_team

    def test_timeline_filters_team(self):
        """Test the timeline only shows the passed in team."""
        with self.app.app_context():
            u = user(save=True, team={})
            u2 = user(username='janedoe', email='[email protected]',
                      slug='janedoe', save=True, team={'name': 'XXX',
                                                       'slug': 'xxx'})
            p = project(save=True)
            status(user=u, project=p, save=True)
            status(user=u2, project=p, save=True)

        response = self.client.get(self._url(dict(team_id=u.teams[0].id)))
        data = json.loads(response.data)
        eq_(len(data), 1)
        eq_(data[0]['user'], u.dictify())
开发者ID:chinna1986,项目名称:standup,代码行数:15,代码来源:test_api2.py


示例14: test_timeline_include_replies

    def test_timeline_include_replies(self):
        """Test the include_replies parameter of home_timeline"""
        with self.app.app_context():
            u = user(save=True, team={})
            p = project(save=True)
            for i in range(10):
                s = status(project=p, user=u, save=True)
            for i in range(10):
                status(project=p, user=u, reply_to=s, save=True)

        response = self.client.get(self._url())
        data = json.loads(response.data)
        eq_(len(data), 10)

        response = self.client.get(self._url(dict(include_replies=1)))
        data = json.loads(response.data)
        eq_(len(data), 20)
开发者ID:chinna1986,项目名称:standup,代码行数:17,代码来源:test_api2.py


示例15: test_project_recent_statuses

    def test_project_recent_statuses(self):
        """Test loading of recent statuses for a project."""
        with self.app.app_context():
            p = project(save=True)
            u = user(save=True)

            # Create 70 statuses
            for i in range(70):
                status(project=p, user=u, save=True)

            s = status(project=p, user=u, save=True)

            # Create 30 replies
            for i in range(30):
                status(project=p, user=u, reply_to=s, save=True)

        # Should not include replies
        page = p.recent_statuses()
        eq_(page.pages, 4)
开发者ID:robhudson,项目名称:standup,代码行数:19,代码来源:test_status.py


示例16: test_timeline_week

    def test_timeline_week(self):
        """Test the week parameter of home_timeline"""
        year = 2014
        month = 5
        day = 23
        date_str = "%04d-%02d-%02d" % (year, month, day)
        with self.app.app_context():
            u = user(save=True, team={})
            p = project(save=True)
            d = datetime(year, month, day)
            s = status(user=u, project=p, save=True, created=d)

        # A badly formatted date should raise ApiError (returning 400)
        response = self.client.get(self._url(dict(week="May 23, 2014")))
        eq_(response.status_code, 400)

        response = self.client.get(self._url(dict(week=date_str)))
        eq_(response.status_code, 200)
        data = json.loads(response.data)
        ok_(data[0]['created'].startswith(date_str))
开发者ID:Ms2ger,项目名称:standup,代码行数:20,代码来源:test_api2.py


示例17: test_format_update

 def test_format_update(self):
     content = ("#merge pull #1 and pR 2 to fix bug #3 and BUg 4 by "
                "@jezdez for @r1cky but not [email protected]")
     with self.app.app_context():
         user(username='r1cky', slug='r1cky', save=True)
         user(username='jezdez', slug='jezdez',
              email='[email protected]',
              github_handle='jezdez',
              save=True)
         p = project(name='mdndev', slug='mdndev',
                     repo_url='https://github.com/mozilla/kuma')
         formatted_update = format_update(content, project=p)
     ok_('tag-merge' in formatted_update)
     ok_('pull/1' in formatted_update)
     ok_('pull/2' in formatted_update)
     ok_('show_bug.cgi?id=3' in formatted_update)
     ok_('show_bug.cgi?id=4' in formatted_update)
     ok_('/user/jezdez' in formatted_update)
     ok_('/user/r1cky' in formatted_update)
     ok_('/user/willkg' not in formatted_update)
     ok_('/user/mozilla.com' not in formatted_update)
开发者ID:Ms2ger,项目名称:standup,代码行数:21,代码来源:test_api.py


示例18: test_feeds

    def test_feeds(self):
        """Test that the site-wise Atom feed appears and functions properly."""
        with self.app.app_context():
            u = user(email='[email protected]', slug='joe', save=True)
            team(users=[u], slug='a-team', save=True)
            p = project(slug='prjkt', save=True)

            for i in range(20):
                status(user=u, project=p, content='foo', content_html='foo',
                       save=True)

        authenticate(self.client, u)

        site_url = self.app.config.get('SITE_URL')

        # Ensure the Atom link appears in the rendered HTML.
        rv = self.client.get('/')
        assert ('<link rel="alternate" type="application/atom+xml" '
                'href="%s/statuses.xml"') % site_url in rv.data

        # Make sure the Atom feed displays statuses.
        rv = self.client.get('/statuses.xml')
        assert '<entry' in rv.data
        assert ('<content type="html">&lt;h3&gt;Test Project&lt;/h3&gt;&lt;p'
                '&gt;foo&lt;/p&gt;</content>') in rv.data

        rv = self.client.get('/user/joe.xml')
        assert '<entry' in rv.data
        assert ('<content type="html">&lt;h3&gt;Test Project&lt;/h3&gt;&lt;p'
                '&gt;foo&lt;/p&gt;</content>') in rv.data

        rv = self.client.get('/project/prjkt.xml')
        assert '<entry' in rv.data
        assert ('<content type="html">&lt;h3&gt;Test Project&lt;/h3&gt;&lt;p'
                '&gt;foo&lt;/p&gt;</content>') in rv.data

        rv = self.client.get('/team/a-team.xml')
        assert '<entry' in rv.data
        assert ('<content type="html">&lt;h3&gt;Test Project&lt;/h3&gt;&lt;p'
                '&gt;foo&lt;/p&gt;</content>') in rv.data
开发者ID:robhudson,项目名称:standup,代码行数:40,代码来源:test_status.py


示例19: test_timeline_max_id

    def test_timeline_max_id(self):
        """Test the max_id parameter of home_timeline"""
        with self.app.app_context():
            u = user(save=True, team={})
            p = project(save=True)
            for i in range(30):
                status(project=p, user=u, save=True)

        response = self.client.get(self._url(dict(max_id=10, count=20)))
        data = json.loads(response.data)
        eq_(len(data), 10)
        eq_(data[0]["id"], 10)

        response = self.client.get(self._url(dict(max_id=10, since_id=5)))
        data = json.loads(response.data)
        eq_(len(data), 5)

        response = self.client.get(self._url(dict(max_id=0)))
        eq_(response.status_code, 400)

        response = self.client.get(self._url(dict(max_id="a")))
        eq_(response.status_code, 400)
开发者ID:safwanrahman,项目名称:standup,代码行数:22,代码来源:test_api2.py


示例20: test_get_statuses

    def test_get_statuses(self):
        """Test getting statuses from API"""
        statuses = []

        with self.app.app_context():
            u = user(save=True)
            p = project(save=True)

            # Create 30 dummy statuses
            for i in range(30):
                if i > 25:
                    p = None
                statuses.append(status(user=u, project=p, save=True))

        # Test with no limit
        response = self.client.get('api/v1/feed/')
        eq_(response.status_code, 200)
        feed = load_json(response.data)

        # Ensure that the default limit works
        eq_(len(feed), 20)

        # Ensure that the correct item are first and last
        eq_(feed.keys()[0], '30', 'First item incorrect')
        eq_(feed.keys()[19], '11', 'Last item incorrect')

        # Test with no limit
        response = self.client.get('api/v1/feed/', query_string={'limit': 5})
        eq_(response.status_code, 200)
        feed = load_json(response.data)

        # Ensure that the default limit works
        eq_(len(feed), 5)

        # Test with no limit
        eq_(feed.keys()[0], '30', 'First item incorrect')
        eq_(feed.keys()[4], '26', 'Last item incorrect')
开发者ID:chinna1986,项目名称:standup,代码行数:37,代码来源:test_api.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python tests.status函数代码示例发布时间:2022-05-27
下一篇:
Python database.get_session函数代码示例发布时间: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