本文整理汇总了Python中tests.factories.UserFactory.get_default_password方法的典型用法代码示例。如果您正苦于以下问题:Python UserFactory.get_default_password方法的具体用法?Python UserFactory.get_default_password怎么用?Python UserFactory.get_default_password使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tests.factories.UserFactory
的用法示例。
在下文中一共展示了UserFactory.get_default_password方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_authenticate_using_token
# 需要导入模块: from tests.factories import UserFactory [as 别名]
# 或者: from tests.factories.UserFactory import get_default_password [as 别名]
def test_authenticate_using_token(self):
user = UserFactory.create()
exists, auth_user = User.authenticate(email=user.email, password=UserFactory.get_default_password())
expect(auth_user).not_to_be_null()
auth_user = User.authenticate_with_token(token=auth_user.token)
expect(auth_user).not_to_be_null()
示例2: test_can_create_user
# 需要导入模块: from tests.factories import UserFactory [as 别名]
# 或者: from tests.factories.UserFactory import get_default_password [as 别名]
def test_can_create_user(self):
user = UserFactory.create()
password = UserFactory.get_default_password()
password = hmac.new(six.b(str(user.salt)), six.b(password), hashlib.sha1).hexdigest()
retrieved = User.objects(id=user.id)
expect(retrieved.count()).to_equal(1)
expect(retrieved.first().password).to_equal(password)
expect(retrieved.first().email).to_equal(user.email)
expect(retrieved.first().token).to_equal(user.token)
示例3: test_default_action_when_user_authenticated_properly
# 需要导入模块: from tests.factories import UserFactory [as 别名]
# 或者: from tests.factories.UserFactory import get_default_password [as 别名]
def test_default_action_when_user_authenticated_properly(self, get_mock, mock_stdout):
user = UserFactory.create()
headers_mock = mock.Mock(get=lambda msg: "test-token-2")
response_mock = mock.Mock(status_code=200, headers=headers_mock)
get_mock.return_value = response_mock
ctrl = self.make_controller(AuthController, conf=self.fixture_for('test.conf'), email=user.email, password=UserFactory.get_default_password())
ctrl.app.user_data = UserData(target=self.get_url('/'))
expect(ctrl.default()).to_be_true()
expect(mock_stdout.getvalue()).to_be_like("Authenticated.")
expect(get_mock.called).to_be_true()
assert_token_is("test-token-2")