def test_setting_tokens(self): """ Токен аккаунта меняется каждый раз, когда вызывается метод смены токена """ account = Account({"login": "******", "password": "******", "token": "123"}).save() new_token = account.set_new_token() account.refresh() self.assertNotEqual("123", account.token) self.assertEqual(new_token, account.token)
def test_change_password(self): """ Сервис аутентификации позволяет менять пароль пользователя """ account = Account({"login": "******", "password": "******", "token": "12345678"}).save() self.assertRaises(IncorrectLogin, AuthentificationService().change_password, "weird_login") new_password = AuthentificationService().change_password("login") account.refresh() self.assertNotEqual("12345", account.password) self.assertEqual(md5(new_password), account.password)