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

Python tests.user函数代码示例

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

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



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

示例1: test_update_user_by_admins

    def test_update_user_by_admins(self):
        """Test that an admin can update another users settings and non-admins
        cannot update other users settings
        """
        u = user(save=True)
        a = user(username="admin", slug="admin", email="[email protected]", is_admin=True, save=True)

        uid = u.id
        aid = a.id
        username = u.username

        data = json.dumps(
            {
                "api_key": settings.API_KEY,
                "user": a.username,
                "email": "[email protected]",
                "github_handle": "test",
                "name": "Test",
            }
        )
        response = self.app.post("/api/v1/user/%s/" % username, data=data, content_type="application/json")
        self.assertEqual(response.status_code, 200)

        u = User.query.get(uid)

        self.assertEqual(u.email, "[email protected]")
        self.assertEqual(u.github_handle, "test")
        self.assertEqual(u.name, "Test")

        data = json.dumps({"api_key": settings.API_KEY, "user": username, "email": "[email protected]"})
        response = self.app.post("/api/v1/user/%s/" % aid, data=data, content_type="application/json")
        self.assertEqual(response.status_code, 403)
开发者ID:uberj,项目名称:standup,代码行数:32,代码来源:test_app.py


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


示例3: test_profile_authenticationified

    def test_profile_authenticationified(self):
        """Test that you can see profile page if you are logged in."""
        user(email='[email protected]', save=True)
        with app.app.test_client() as tc:
            with tc.session_transaction() as sess:
                sess['email'] = '[email protected]'

            rv = tc.get('/profile/')
            eq_(rv.status_code, 200)
开发者ID:hsgr,项目名称:standup,代码行数:9,代码来源:test_app.py


示例4: test_status

    def test_status(self):
        """Test posting a status."""
        user(email='[email protected]', save=True)
        with app.app.test_client() as tc:
            with tc.session_transaction() as sess:
                sess['email'] = '[email protected]'

            rv = tc.post('/statusize/',
                         data={'message': 'foo'},
                         follow_redirects=True)
            eq_(rv.status_code, 200)
开发者ID:hsgr,项目名称:standup,代码行数:11,代码来源:test_app.py


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


示例6: test_status_no_message

    def test_status_no_message(self):
        """Test posting a status with no message."""
        user(email='[email protected]', save=True)
        with app.app.test_client() as tc:
            with tc.session_transaction() as sess:
                sess['email'] = '[email protected]'

            rv = tc.post('/statusize/',
                         data={'message': ''},
                         follow_redirects=True)
            # This kicks up a 404, but that's lame.
            eq_(rv.status_code, 404)
开发者ID:hsgr,项目名称:standup,代码行数:12,代码来源:test_app.py


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


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


示例9: test_status_repr

    def test_status_repr(self):
        """Test the __repr__ function of the Status model."""
        with self.app.app_context():
            u = user(username='testuser', save=True)
            s = status(content='my status update', user=u, save=True)

        eq_(repr(s), '<Status: testuser: my status update>')
开发者ID:robhudson,项目名称:standup,代码行数:7,代码来源:test_status.py


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


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


示例12: test_status_with_project

    def test_status_with_project(self):
        """Test posting a status with no message."""
        user(email='[email protected]', save=True)

        p = Project(name='blackhole', slug='blackhole')
        app.db.session.add(p)
        app.db.session.commit()
        pid = p.id

        with app.app.test_client() as tc:
            with tc.session_transaction() as sess:
                sess['email'] = '[email protected]'

            rv = tc.post('/statusize/',
                         data={'message': 'r1cky rocks!', 'project': pid},
                         follow_redirects=True)
            eq_(rv.status_code, 200)
开发者ID:hsgr,项目名称:standup,代码行数:17,代码来源:test_app.py


示例13: test_status_week_end

 def test_status_week_end(self):
     """Test the week_end function of the Status model."""
     d = datetime(2014, 5, 8, 17, 17, 51, 0)
     with self.app.app_context():
         u = user(username='testuser', save=True)
         s = status(content='my status update', created=d, user=u, save=True)
     d_actual = s.week_end.strftime("%Y-%m-%d")
     eq_(d_actual, "2014-05-11") # Happy Mother's Day!
开发者ID:rlr,项目名称:standup,代码行数:8,代码来源:test_status.py


示例14: setUp

    def setUp(self):
        super(TimesinceLastUpdateTestCase, self).setUp()

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

        self.url = '/api/v2/info/timesince_last_update.json'
        self.query = {'screen_name': self.user.username}
开发者ID:chinna1986,项目名称:standup,代码行数:8,代码来源:test_api2.py


示例15: test_status_weeks_at_year_start

 def test_status_weeks_at_year_start(self):
     """Test the week_{start|end} function around the start of the year."""
     d = datetime(2013, 12, 31, 12, 13, 45, 0)
     with self.app.app_context():
         u = user(username='testuser', save=True)
         s = status(content='my status update', created=d, user=u, save=True)
     eq_(s.week_start.strftime("%Y-%m-%d"), "2013-12-30")
     eq_(s.week_end.strftime("%Y-%m-%d"), "2014-01-05")
开发者ID:rlr,项目名称:standup,代码行数:8,代码来源:test_status.py


示例16: test_update_user_validation

    def test_update_user_validation(self):
        """Verify validation of required fields"""
        u = user(save=True)

        # Missing user
        data = json.dumps({"api_key": settings.API_KEY})
        response = self.app.post("/api/v1/user/%s/" % u.id, data=data, content_type="application/json")
        self.assertEqual(response.status_code, 400)
开发者ID:uberj,项目名称:standup,代码行数:8,代码来源:test_app.py


示例17: test_udate_user_invalid_api_key

 def test_udate_user_invalid_api_key(self):
     """Request with invalid API key should return 403"""
     u = user(save=True)
     data = json.dumps({'user': u.username})
     response = self.app.post(
         '/api/v1/user/%s/' % u.id, data=data,
         content_type='application/json')
     self.assertEqual(response.status_code, 403)
开发者ID:groovecoder,项目名称:standup,代码行数:8,代码来源:test_app.py


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


示例19: test_profile_authenticated

    def test_profile_authenticated(self):
        """Test that you can see profile page if you are logged in."""
        with self.app.app_context():
            u = user(email='[email protected]', save=True)

        authenticate(self.client, u)

        response = self.client.get('/profile/')
        eq_(response.status_code, 200)
开发者ID:Ms2ger,项目名称:standup,代码行数:9,代码来源:test_users.py


示例20: setUp

    def setUp(self):
        super(TeamMembersTestCase, self).setUp()

        self.query = {"slug": "test"}
        self.url = "/api/v2/teams/members.json"

        with self.app.app_context():
            self.team = team(slug=self.query["slug"], name="Test Team", save=True)
            self.user = user(save=True)
开发者ID:safwanrahman,项目名称:standup,代码行数:9,代码来源:test_api2.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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