forked from piccolo-orm/piccolo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_create.py
More file actions
54 lines (48 loc) · 1.5 KB
/
test_create.py
File metadata and controls
54 lines (48 loc) · 1.5 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from unittest import TestCase
from unittest.mock import patch
from piccolo.apps.user.commands.create import create
from piccolo.apps.user.tables import BaseUser
class TestCreate(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.create.get_username",
return_value="bob123",
)
@patch(
"piccolo.apps.user.commands.create.get_email",
return_value="bob@test.com",
)
@patch(
"piccolo.apps.user.commands.create.get_password",
return_value="password123",
)
@patch(
"piccolo.apps.user.commands.create.get_confirmed_password",
return_value="password123",
)
@patch(
"piccolo.apps.user.commands.create.get_is_admin", return_value=True,
)
@patch(
"piccolo.apps.user.commands.create.get_is_superuser",
return_value=True,
)
@patch(
"piccolo.apps.user.commands.create.get_is_active", return_value=True,
)
def test_create(self, *args, **kwargs):
create()
self.assertTrue(
BaseUser.exists()
.where(
(BaseUser.admin == True) # noqa: E712
& (BaseUser.username == "bob123")
& (BaseUser.email == "bob@test.com")
& (BaseUser.superuser == True)
& (BaseUser.active == True)
)
.run_sync()
)