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


Python user_factory.create函数代码示例

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


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

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

示例2: test_user_api_key

 def test_user_api_key(self):
     user = user_factory.create(api_key="user_key")
     path = '/api/queries/'
     with app.test_client() as c:
         signature = sign(user.api_key, path, self.expires)
         rv = c.get(path, query_string={'signature': signature, 'expires': self.expires, 'user_id': user.id})
         self.assertEqual(user.id, hmac_load_user_from_request(request).id)
开发者ID:none4uhiggins,项目名称:redash,代码行数:7,代码来源:test_authentication.py

示例3: test_submit_incorrect_password

    def test_submit_incorrect_password(self):
        user = user_factory.create()

        with app.test_client() as c, patch('redash.controllers.login_user') as login_user_mock:
            rv = c.post('/login', data={'username': user.email, 'password': ''})
            self.assertEquals(rv.status_code, 200)
            self.assertFalse(login_user_mock.called)
开发者ID:daamien,项目名称:redash,代码行数:7,代码来源:test_controllers.py

示例4: 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:daamien,项目名称:redash,代码行数:7,代码来源:test_controllers.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:daamien,项目名称:redash,代码行数:7,代码来源:test_controllers.py

示例6: authenticated_user

def authenticated_user(c, user=None):
    if not user:
        user = user_factory.create()
        db.session.commit()
    authenticate_request(c, user)

    yield user
开发者ID:rohithreddy,项目名称:redash,代码行数:7,代码来源:__init__.py

示例7: test_submit_incorrect_password

    def test_submit_incorrect_password(self):
        user = user_factory.create()

        with app.test_client() as c, patch("redash.controllers.login_user") as login_user_mock:
            rv = c.post("/login", data={"email": user.email, "password": ""})
            self.assertEquals(rv.status_code, 200)
            self.assertFalse(login_user_mock.called)
开发者ID:none4uhiggins,项目名称:redash,代码行数:7,代码来源:test_controllers.py

示例8: authenticated_user

def authenticated_user(c, user=None):
    if not user:
        user = user_factory.create()

    with c.session_transaction() as sess:
        sess['user_id'] = user.id

    yield
开发者ID:daamien,项目名称:redash,代码行数:8,代码来源:test_controllers.py

示例9: 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:none4uhiggins,项目名称:redash,代码行数:8,代码来源:test_controllers.py

示例10: 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:daamien,项目名称:redash,代码行数:9,代码来源:test_controllers.py

示例11: test_submit_incorrect_password

    def test_submit_incorrect_password(self):
        user = user_factory.create()
        user.hash_password('password')
        user.save()

        with app.test_client() as c, patch('redash.handlers.authentication.login_user') as login_user_mock:
            rv = c.post('/login', data={'email': user.email, 'password': 'badbadpassword'})
            self.assertEquals(rv.status_code, 200)
            self.assertFalse(login_user_mock.called)
开发者ID:carezone,项目名称:redash,代码行数:9,代码来源:test_handlers.py

示例12: test_submit_correct_user_and_password_and_remember_me

    def test_submit_correct_user_and_password_and_remember_me(self):
        user = user_factory.create()
        user.hash_password('password')
        user.save()

        with app.test_client() as c, patch('redash.controllers.login_user') as login_user_mock:
            rv = c.post('/login', data={'username': user.email, 'password': 'password', 'remember': True})
            self.assertEquals(rv.status_code, 302)
            login_user_mock.assert_called_with(user, remember=True)
开发者ID:daamien,项目名称:redash,代码行数:9,代码来源:test_controllers.py

示例13: 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:none4uhiggins,项目名称:redash,代码行数:9,代码来源:test_controllers.py

示例14: 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:daamien,项目名称:redash,代码行数:10,代码来源:test_controllers.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


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