|
@@ -2,11 +2,27 @@
|
2
|
2
|
import os
|
3
|
3
|
import subprocess
|
4
|
4
|
|
|
5
|
+import pytest
|
|
6
|
+import transaction
|
|
7
|
+from pkg_resources import load_entry_point
|
|
8
|
+from sqlalchemy.orm.exc import NoResultFound
|
|
9
|
+
|
5
|
10
|
import tracim
|
|
11
|
+from tracim.command import TracimCLI
|
|
12
|
+from tracim.command.user import UserCommand
|
|
13
|
+from tracim.exceptions import UserNotExist
|
|
14
|
+from tracim.lib.core.user import UserApi
|
|
15
|
+from tracim.tests import CommandFunctionalTest
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+class TestCommands(CommandFunctionalTest):
|
|
19
|
+ """
|
|
20
|
+ Test tracimcli command line ui.
|
|
21
|
+ """
|
6
|
22
|
|
|
23
|
+ config_section = 'app:command_test'
|
7
|
24
|
|
8
|
|
-class TestCommands(object):
|
9
|
|
- def test_commands(self):
|
|
25
|
+ def test_func__check_commands_list__ok__nominal_case(self):
|
10
|
26
|
"""
|
11
|
27
|
Test listing of tracimcli command: Tracim commands must be listed
|
12
|
28
|
:return:
|
|
@@ -20,3 +36,52 @@ class TestCommands(object):
|
20
|
36
|
assert output.find('user update') > 0
|
21
|
37
|
assert output.find('db init') > 0
|
22
|
38
|
assert output.find('db delete') > 0
|
|
39
|
+ assert output.find('webdav start') > 0
|
|
40
|
+
|
|
41
|
+ def test_func__user_create_command__ok__nominal_case(self):
|
|
42
|
+ """
|
|
43
|
+ Test User creation
|
|
44
|
+ """
|
|
45
|
+ api = UserApi(
|
|
46
|
+ current_user=None,
|
|
47
|
+ session=self.session,
|
|
48
|
+ config=self.app_config,
|
|
49
|
+ )
|
|
50
|
+ with pytest.raises(NoResultFound):
|
|
51
|
+ api.get_one_by_email('command_test@user')
|
|
52
|
+ app = TracimCLI()
|
|
53
|
+ result = app.run([
|
|
54
|
+ 'user', 'create',
|
|
55
|
+ '-c', 'tests_configs.ini#command_test',
|
|
56
|
+ '-l', 'command_test@user',
|
|
57
|
+ '-p', 'new_password'
|
|
58
|
+ ])
|
|
59
|
+ new_user = api.get_one_by_email('command_test@user')
|
|
60
|
+ assert new_user.email == 'command_test@user'
|
|
61
|
+ assert new_user.validate_password('new_password')
|
|
62
|
+
|
|
63
|
+ def test_func__user_update_command__ok__nominal_case(self):
|
|
64
|
+ """
|
|
65
|
+ Test user password update
|
|
66
|
+ """
|
|
67
|
+ api = UserApi(
|
|
68
|
+ current_user=None,
|
|
69
|
+ session=self.session,
|
|
70
|
+ config=self.app_config,
|
|
71
|
+ )
|
|
72
|
+ user = api.get_one_by_email('admin@admin.admin')
|
|
73
|
+ assert user.email == 'admin@admin.admin'
|
|
74
|
+ assert user.validate_password('admin@admin.admin')
|
|
75
|
+ assert not user.validate_password('new_password')
|
|
76
|
+
|
|
77
|
+ app = TracimCLI()
|
|
78
|
+ result = app.run([
|
|
79
|
+ 'user', 'update',
|
|
80
|
+ '-c', 'tests_configs.ini#command_test',
|
|
81
|
+ '-l', 'admin@admin.admin',
|
|
82
|
+ '-p', 'new_password'
|
|
83
|
+ ])
|
|
84
|
+ new_user = api.get_one_by_email('admin@admin.admin')
|
|
85
|
+ assert new_user.email == 'admin@admin.admin'
|
|
86
|
+ assert new_user.validate_password('new_password')
|
|
87
|
+ assert not new_user.validate_password('admin@admin.admin')
|