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

Python handlers.authenticated_user函数代码示例

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

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



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

示例1: test_returns_400_when_configuration_invalid

    def test_returns_400_when_configuration_invalid(self):
        admin = user_factory.create(groups=['admin', 'default'])
        with app.test_client() as c, authenticated_user(c, user=admin):
            rv = json_request(c.post, '/api/data_sources',
                              data={'name': 'DS 1', 'type': 'pg', 'options': '{}'})

            self.assertEqual(rv.status_code, 400)
开发者ID:carezone,项目名称:redash,代码行数:7,代码来源:test_handlers.py


示例2: test_logout_when_loggedin

 def test_logout_when_loggedin(self):
     with app.test_client() as c, authenticated_user(c, user=self.factory.user):
         rv = c.get('/default/')
         self.assertTrue(current_user.is_authenticated)
         rv = c.get('/default/logout')
         self.assertEquals(rv.status_code, 302)
         self.assertFalse(current_user.is_authenticated)
开发者ID:5t111111,项目名称:redash,代码行数:7,代码来源:test_handlers.py


示例3: test_logout_when_loggedin

 def test_logout_when_loggedin(self):
     with app.test_client() as c, authenticated_user(c):
         rv = c.get('/')
         self.assertTrue(current_user.is_authenticated())
         rv = c.get('/logout')
         self.assertEquals(rv.status_code, 302)
         self.assertFalse(current_user.is_authenticated())
开发者ID:carezone,项目名称:redash,代码行数:7,代码来源:test_handlers.py


示例4: test_returns_200_for_admin_changing_other_user

    def test_returns_200_for_admin_changing_other_user(self):
        admin = user_factory.create(groups=['admin', 'default'])
        user = user_factory.create()

        with app.test_client() as c, authenticated_user(c, user=admin):
            rv = json_request(c.post, "/api/users/{}".format(user.id), data={"name": "New Name"})
            self.assertEqual(rv.status_code, 200)
开发者ID:carezone,项目名称:redash,代码行数:7,代码来源:test_users.py


示例5: test_creates_data_source

    def test_creates_data_source(self):
        admin = user_factory.create(groups=['admin', 'default'])
        with app.test_client() as c, authenticated_user(c, user=admin):
            rv = json_request(c.post, '/api/data_sources',
                              data={'name': 'DS 1', 'type': 'pg', 'options': {"dbname": "redash"}})

            self.assertEqual(rv.status_code, 200)
开发者ID:carezone,项目名称:redash,代码行数:7,代码来源:test_handlers.py


示例6: test_update_dashboard

 def test_update_dashboard(self):
     d = dashboard_factory.create()
     new_name = 'New Name'
     with app.test_client() as c, authenticated_user(c):
         rv = json_request(c.post, '/api/dashboards/{0}'.format(d.id),
                           data={'name': new_name, 'layout': '[]'})
         self.assertEquals(rv.status_code, 200)
         self.assertEquals(rv.json['name'], new_name)
开发者ID:carezone,项目名称:redash,代码行数:8,代码来源:test_handlers.py


示例7: test_delete_dashboard

    def test_delete_dashboard(self):
        d = dashboard_factory.create()
        with app.test_client() as c, authenticated_user(c):
            rv = json_request(c.delete, '/api/dashboards/{0}'.format(d.slug))
            self.assertEquals(rv.status_code, 200)

            d = models.Dashboard.get_by_slug(d.slug)
            self.assertTrue(d.is_archived)
开发者ID:carezone,项目名称:redash,代码行数:8,代码来源:test_handlers.py


示例8: test_delete_visualization

    def test_delete_visualization(self):
        visualization = visualization_factory.create()
        with app.test_client() as c, authenticated_user(c):
            rv = json_request(c.delete, '/api/visualizations/{0}'.format(visualization.id))

            self.assertEquals(rv.status_code, 200)
            # =1 because each query has a default table visualization.
            self.assertEquals(models.Visualization.select().count(), 1)
开发者ID:carezone,项目名称:redash,代码行数:8,代码来源:test_handlers.py


示例9: test_get_all_queries

    def test_get_all_queries(self):
        queries = [query_factory.create() for _ in range(10)]

        with app.test_client() as c, authenticated_user(c):
            rv = json_request(c.get, '/api/queries')

            self.assertEquals(rv.status_code, 200)
            self.assertEquals(len(rv.json), 10)
开发者ID:carezone,项目名称:redash,代码行数:8,代码来源:test_handlers.py


示例10: test_get_query

    def test_get_query(self):
        query = query_factory.create()

        with app.test_client() as c, authenticated_user(c):
            rv = json_request(c.get, '/api/queries/{0}'.format(query.id))

            self.assertEquals(rv.status_code, 200)
            self.assertResponseEqual(rv.json, query.to_dict(with_visualizations=True))
开发者ID:carezone,项目名称:redash,代码行数:8,代码来源:test_handlers.py


示例11: test_returns_400_when_missing_fields

    def test_returns_400_when_missing_fields(self):
        admin = user_factory.create(groups=['admin', 'default'])
        with app.test_client() as c, authenticated_user(c, user=admin):
            rv = c.post("/api/data_sources")
            self.assertEqual(rv.status_code, 400)

            rv = json_request(c.post, '/api/data_sources', data={'name': 'DS 1'})

            self.assertEqual(rv.status_code, 400)
开发者ID:carezone,项目名称:redash,代码行数:9,代码来源:test_handlers.py


示例12: test_update_visualization

    def test_update_visualization(self):
        visualization = visualization_factory.create()

        with app.test_client() as c, authenticated_user(c):
            rv = json_request(c.post, '/api/visualizations/{0}'.format(visualization.id),
                              data={'name': 'After Update'})

            self.assertEquals(rv.status_code, 200)
            self.assertEquals(rv.json['name'], 'After Update')
开发者ID:carezone,项目名称:redash,代码行数:9,代码来源:test_handlers.py


示例13: test_create_new_dashboard

 def test_create_new_dashboard(self):
     user = user_factory.create()
     with app.test_client() as c, authenticated_user(c, user=user):
         dashboard_name = 'Test Dashboard'
         rv = json_request(c.post, '/api/dashboards', data={'name': dashboard_name})
         self.assertEquals(rv.status_code, 200)
         self.assertEquals(rv.json['name'], 'Test Dashboard')
         self.assertEquals(rv.json['user_id'], user.id)
         self.assertEquals(rv.json['layout'], [])
开发者ID:carezone,项目名称:redash,代码行数:9,代码来源:test_handlers.py


示例14: test_get_dashboard

    def test_get_dashboard(self):
        d1 = dashboard_factory.create()
        with app.test_client() as c, authenticated_user(c):
            rv = c.get('/api/dashboards/{0}'.format(d1.slug))
            self.assertEquals(rv.status_code, 200)

            expected = d1.to_dict(with_widgets=True)
            actual = json.loads(rv.data)

            self.assertResponseEqual(expected, actual)
开发者ID:carezone,项目名称:redash,代码行数:10,代码来源:test_handlers.py


示例15: test_creates_user

    def test_creates_user(self):
        admin = user_factory.create(groups=['admin', 'default'])

        with app.test_client() as c, authenticated_user(c, user=admin):
            test_user = {'name': 'User', 'email': '[email protected]', 'password': 'test'}
            rv = json_request(c.post, '/api/users', data=test_user)

            self.assertEqual(rv.status_code, 200)
            self.assertEqual(rv.json['name'], test_user['name'])
            self.assertEqual(rv.json['email'], test_user['email'])
开发者ID:carezone,项目名称:redash,代码行数:10,代码来源:test_users.py


示例16: test_update_query

    def test_update_query(self):
        query = query_factory.create()

        other_user = user_factory.create()

        with app.test_client() as c, authenticated_user(c, user=other_user):
            rv = json_request(c.post, '/api/queries/{0}'.format(query.id), data={'name': 'Testing'})
            self.assertEqual(rv.status_code, 200)
            self.assertEqual(rv.json['name'], 'Testing')
            self.assertEqual(rv.json['last_modified_by']['id'], other_user.id)
开发者ID:carezone,项目名称:redash,代码行数:10,代码来源:test_handlers.py


示例17: test_post_result_list

    def test_post_result_list(self):
        data_source = data_source_factory.create()
        query_result = query_result_factory.create()
        query = query_factory.create()

        with app.test_client() as c, authenticated_user(c):
            rv = json_request(c.post, '/api/query_results',
                              data={'data_source_id': data_source.id,
                                    'query': query.query})
            self.assertEquals(rv.status_code, 200)
开发者ID:carezone,项目名称:redash,代码行数:10,代码来源:test_handlers.py


示例18: test_delete_widget

    def test_delete_widget(self):
        widget = widget_factory.create()

        with app.test_client() as c, authenticated_user(c):
            rv = json_request(c.delete, '/api/widgets/{0}'.format(widget.id))

            self.assertEquals(rv.status_code, 200)
            dashboard = models.Dashboard.get_by_slug(widget.dashboard.slug)
            self.assertEquals(dashboard.widgets.count(), 0)
            self.assertEquals(dashboard.layout, '[]')
开发者ID:carezone,项目名称:redash,代码行数:10,代码来源:test_handlers.py


示例19: create_widget

    def create_widget(self, dashboard, visualization, width=1):
        data = {
            'visualization_id': visualization.id,
            'dashboard_id': dashboard.id,
            'options': {},
            'width': width
        }

        with app.test_client() as c, authenticated_user(c):
            rv = json_request(c.post, '/api/widgets', data=data)

        return rv
开发者ID:carezone,项目名称:redash,代码行数:12,代码来源:test_handlers.py


示例20: test_changes_password

    def test_changes_password(self):
        new_password = "new password"
        old_password = "old password"
        with app.test_client() as c, authenticated_user(c) as user:
            user.hash_password(old_password)
            user.save()

            rv = json_request(c.post, "/api/users/{}".format(user.id), data={"password": new_password, "old_password": old_password})
            self.assertEqual(rv.status_code, 200)

            user = models.User.get_by_id(user.id)
            self.assertTrue(user.verify_password(new_password))
开发者ID:carezone,项目名称:redash,代码行数:12,代码来源:test_users.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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