forked from piccolo-orm/piccolo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_change_password.py
More file actions
36 lines (29 loc) · 1.03 KB
/
test_change_password.py
File metadata and controls
36 lines (29 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from unittest import TestCase
from unittest.mock import patch
from piccolo.apps.user.commands.change_password import change_password
from piccolo.apps.user.tables import BaseUser
class TestChangePassword(TestCase):
def setUp(self):
BaseUser.create_table(if_not_exists=True).run_sync()
def tearDown(self):
BaseUser.alter().drop_table().run_sync()
@patch(
"piccolo.apps.user.commands.change_password.get_username",
return_value="bob123",
)
@patch(
"piccolo.apps.user.commands.change_password.get_password",
return_value="new_password",
)
@patch(
"piccolo.apps.user.commands.change_password.get_confirmed_password",
return_value="new_password",
)
def test_create(self, *args, **kwargs):
user = BaseUser(username="bob123", password="old_password")
user.save().run_sync()
change_password()
self.assertTrue(
BaseUser.login_sync(username="bob123", password="new_password")
is not None
)