Show More
@@ -1,70 +1,114 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 |
|
2 | |||
3 | # Copyright (C) 2010-2016 RhodeCode GmbH |
|
3 | # Copyright (C) 2010-2016 RhodeCode GmbH | |
4 | # |
|
4 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
5 | # This program is free software: you can redistribute it and/or modify | |
6 | # it under the terms of the GNU Affero General Public License, version 3 |
|
6 | # it under the terms of the GNU Affero General Public License, version 3 | |
7 | # (only), as published by the Free Software Foundation. |
|
7 | # (only), as published by the Free Software Foundation. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU Affero General Public License |
|
14 | # You should have received a copy of the GNU Affero General Public License | |
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | # |
|
16 | # | |
17 | # This program is dual-licensed. If you wish to learn more about the |
|
17 | # This program is dual-licensed. If you wish to learn more about the | |
18 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
18 | # RhodeCode Enterprise Edition, including its added features, Support services, | |
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ | |
20 |
|
20 | |||
21 | import mock |
|
21 | import mock | |
22 | import pytest |
|
22 | import pytest | |
23 |
|
23 | |||
|
24 | import rhodecode | |||
|
25 | from rhodecode.model.settings import SettingsModel | |||
24 | from rhodecode.tests import url, HG_REPO |
|
26 | from rhodecode.tests import url, HG_REPO | |
25 | from rhodecode.tests.utils import AssertResponse |
|
27 | from rhodecode.tests.utils import AssertResponse | |
26 |
|
28 | |||
27 |
|
29 | |||
28 | @pytest.mark.usefixtures('autologin_user', 'app') |
|
30 | @pytest.mark.usefixtures('autologin_user', 'app') | |
29 | class TestAdminRepoSettingsController: |
|
31 | class TestAdminRepoSettingsController: | |
30 | @pytest.mark.parametrize('urlname', [ |
|
32 | @pytest.mark.parametrize('urlname', [ | |
31 | 'edit_repo', |
|
33 | 'edit_repo', | |
32 | 'edit_repo_perms', |
|
34 | 'edit_repo_perms', | |
33 | 'edit_repo_advanced', |
|
35 | 'edit_repo_advanced', | |
34 | 'repo_vcs_settings', |
|
36 | 'repo_vcs_settings', | |
35 | 'edit_repo_fields', |
|
37 | 'edit_repo_fields', | |
36 | 'repo_settings_issuetracker', |
|
38 | 'repo_settings_issuetracker', | |
37 | 'edit_repo_caches', |
|
39 | 'edit_repo_caches', | |
38 | 'edit_repo_remote', |
|
40 | 'edit_repo_remote', | |
39 | 'edit_repo_statistics', |
|
41 | 'edit_repo_statistics', | |
40 | ]) |
|
42 | ]) | |
41 | def test_simple_get(self, urlname, app): |
|
43 | def test_simple_get(self, urlname, app): | |
42 | app.get(url(urlname, repo_name=HG_REPO)) |
|
44 | app.get(url(urlname, repo_name=HG_REPO)) | |
43 |
|
45 | |||
44 | @pytest.mark.parametrize('setting_name', [ |
|
46 | @pytest.mark.parametrize('setting_name, setting_backends', [ | |
45 |
' |
|
47 | ('hg_use_rebase_for_merging', ['hg']), | |
46 | ]) |
|
48 | ]) | |
47 |
def test_labs_settings_enabled |
|
49 | def test_labs_settings_visible_if_enabled( | |
48 | import rhodecode |
|
50 | self, setting_name, setting_backends, backend): | |
49 | vcs_settings_url = url('repo_vcs_settings', repo_name=HG_REPO) |
|
51 | if backend.alias not in setting_backends: | |
|
52 | pytest.skip('Setting not available for backend {}'.format(backend)) | |||
|
53 | ||||
|
54 | vcs_settings_url = url( | |||
|
55 | 'repo_vcs_settings', repo_name=backend.repo.repo_name) | |||
50 |
|
56 | |||
51 | with mock.patch.dict( |
|
57 | with mock.patch.dict( | |
52 | rhodecode.CONFIG, {'labs_settings_active': 'true'}): |
|
58 | rhodecode.CONFIG, {'labs_settings_active': 'true'}): | |
53 | response = self.app.get(vcs_settings_url) |
|
59 | response = self.app.get(vcs_settings_url) | |
54 |
|
60 | |||
55 | assertr = AssertResponse(response) |
|
61 | assertr = AssertResponse(response) | |
56 | assertr.one_element_exists('#{}'.format(setting_name)) |
|
62 | assertr.one_element_exists('#rhodecode_{}'.format(setting_name)) | |
57 |
|
63 | |||
58 | @pytest.mark.parametrize('setting_name', [ |
|
64 | @pytest.mark.parametrize('setting_name, setting_backends', [ | |
59 |
' |
|
65 | ('hg_use_rebase_for_merging', ['hg']), | |
60 | ]) |
|
66 | ]) | |
61 |
def test_labs_settings_disabled |
|
67 | def test_labs_settings_not_visible_if_disabled( | |
62 | import rhodecode |
|
68 | self, setting_name, setting_backends, backend): | |
63 | vcs_settings_url = url('repo_vcs_settings', repo_name=HG_REPO) |
|
69 | if backend.alias not in setting_backends: | |
|
70 | pytest.skip('Setting not available for backend {}'.format(backend)) | |||
|
71 | ||||
|
72 | vcs_settings_url = url( | |||
|
73 | 'repo_vcs_settings', repo_name=backend.repo.repo_name) | |||
64 |
|
74 | |||
65 | with mock.patch.dict( |
|
75 | with mock.patch.dict( | |
66 | rhodecode.CONFIG, {'labs_settings_active': 'false'}): |
|
76 | rhodecode.CONFIG, {'labs_settings_active': 'false'}): | |
67 | response = self.app.get(vcs_settings_url) |
|
77 | response = self.app.get(vcs_settings_url) | |
68 |
|
78 | |||
69 | assertr = AssertResponse(response) |
|
79 | assertr = AssertResponse(response) | |
70 | assertr.no_element_exists('#{}'.format(setting_name)) |
|
80 | assertr.no_element_exists('#rhodecode_{}'.format(setting_name)) | |
|
81 | ||||
|
82 | @pytest.mark.parametrize('setting_name, setting_backends', [ | |||
|
83 | ('hg_use_rebase_for_merging', ['hg']), | |||
|
84 | ]) | |||
|
85 | def test_update_boolean_settings( | |||
|
86 | self, csrf_token, setting_name, setting_backends, backend): | |||
|
87 | if backend.alias not in setting_backends: | |||
|
88 | pytest.skip('Setting not available for backend {}'.format(backend)) | |||
|
89 | ||||
|
90 | settings_model = SettingsModel(repo=backend.repo) | |||
|
91 | vcs_settings_url = url( | |||
|
92 | 'repo_vcs_settings', repo_name=backend.repo.repo_name) | |||
|
93 | ||||
|
94 | self.app.post( | |||
|
95 | vcs_settings_url, | |||
|
96 | params={ | |||
|
97 | 'new_svn_branch': 'dummy-value-for-testing', | |||
|
98 | 'new_svn_tag': 'dummy-value-for-testing', | |||
|
99 | 'rhodecode_{}'.format(setting_name): 'true', | |||
|
100 | 'csrf_token': csrf_token, | |||
|
101 | }) | |||
|
102 | setting = settings_model.get_setting_by_name(setting_name) | |||
|
103 | assert setting.app_settings_value | |||
|
104 | ||||
|
105 | self.app.post( | |||
|
106 | vcs_settings_url, | |||
|
107 | params={ | |||
|
108 | 'new_svn_branch': 'dummy-value-for-testing', | |||
|
109 | 'new_svn_tag': 'dummy-value-for-testing', | |||
|
110 | 'rhodecode_{}'.format(setting_name): 'false', | |||
|
111 | 'csrf_token': csrf_token, | |||
|
112 | }) | |||
|
113 | setting = settings_model.get_setting_by_name(setting_name) | |||
|
114 | assert not setting.app_settings_value |
General Comments 0
You need to be logged in to leave comments.
Login now