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


Python tests.status函数代码示例

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


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

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

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

示例3: test_timesince

 def test_timesince(self):
     """Test the timesince last update endpoint."""
     with self.app.app_context():
         status(user_id=self.user.id, save=True)
     url = '%s?%s' % (self.url, urlencode(self.query))
     response = self.client.get(url)
     eq_(response.status_code, 200)
     eq_(response.data, '{"timesince": 0}')
开发者ID:chinna1986,项目名称:standup,代码行数:8,代码来源:test_api2.py

示例4: test_status_reply_count

    def test_status_reply_count(self):
        """Test the reply_count property of the Status model."""
        with self.app.app_context():
            u = user(save=True)
            s = status(user=u, project=None, save=True)
            for i in range(5):
                status(user=u, project=None, reply_to=s, save=True)

            eq_(s.reply_count, 5)
开发者ID:robhudson,项目名称:standup,代码行数:9,代码来源:test_status.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: setUp

    def setUp(self):
        super(HelpersTestCase, self).setUp()
        with self.app.app_context():
            u = user(username='jdoe', save=True)
            for i in range(100):
                status(project=None, user=u, save=True)

        db = get_session(self.app)
        self.query = db.query(Status).order_by(Status.id)
开发者ID:Ms2ger,项目名称:standup,代码行数:9,代码来源:test_database.py

示例7: test_timeline_filters_user

    def test_timeline_filters_user(self):
        """Test the timeline only shows the passed in user."""
        with self.app.app_context():
            u = user(save=True)
            status(user=u, project=None, save=True)
            u2 = user(username="janedoe", email="[email protected]", slug="janedoe", save=True)
            status(user=u2, project=None, save=True)

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

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

示例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_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

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

示例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_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

示例15: test_create_reply

    def test_create_reply(self):
        """Test creation of replies"""
        s = status(save=True)
        sid = s.id

        data = json.dumps({
            'api_key': settings.API_KEY,
            'user': 'r1cky',
            'content': 'reply to status',
            'reply_to': sid})
        response = self.app.post(
            '/api/v1/status/', data=data, content_type='application/json')
        self.assertEqual(response.status_code, 200)

        # Verify that the status is actually a reply
        r = Status.query.filter(Status.reply_to_id==sid).first()
        self.assertEqual(r.content, 'reply to status')

        # Verify that the reply is included in the list of replies
        s = Status.query.get(sid)
        assert r in s.replies().items

        # You should not be able to reply to the reply
        data = json.dumps({
            'api_key': settings.API_KEY,
            'user': 'r1cky',
            'content': 'should not work',
            'reply_to': r.id})
        response = self.app.post(
            '/api/v1/status/', data=data, content_type='application/json')
        self.assertEqual(response.status_code, 400)
开发者ID:B-Rich,项目名称:standup,代码行数:31,代码来源:test_app.py


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