Show More
@@ -1,114 +1,118 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 |
|
24 | import rhodecode | |
25 | from rhodecode.model.settings import SettingsModel |
|
25 | from rhodecode.model.settings import SettingsModel | |
26 | from rhodecode.tests import url, HG_REPO |
|
26 | from rhodecode.tests import url, HG_REPO | |
27 | from rhodecode.tests.utils import AssertResponse |
|
27 | from rhodecode.tests.utils import AssertResponse | |
28 |
|
28 | |||
29 |
|
29 | |||
30 | @pytest.mark.usefixtures('autologin_user', 'app') |
|
30 | @pytest.mark.usefixtures('autologin_user', 'app') | |
31 | class TestAdminRepoSettingsController: |
|
31 | class TestAdminRepoSettingsController: | |
32 | @pytest.mark.parametrize('urlname', [ |
|
32 | @pytest.mark.parametrize('urlname', [ | |
33 | 'edit_repo', |
|
33 | 'edit_repo', | |
34 | 'edit_repo_perms', |
|
34 | 'edit_repo_perms', | |
35 | 'edit_repo_advanced', |
|
35 | 'edit_repo_advanced', | |
36 | 'repo_vcs_settings', |
|
36 | 'repo_vcs_settings', | |
37 | 'edit_repo_fields', |
|
37 | 'edit_repo_fields', | |
38 | 'repo_settings_issuetracker', |
|
38 | 'repo_settings_issuetracker', | |
39 | 'edit_repo_caches', |
|
39 | 'edit_repo_caches', | |
40 | 'edit_repo_remote', |
|
40 | 'edit_repo_remote', | |
41 | 'edit_repo_statistics', |
|
41 | 'edit_repo_statistics', | |
42 | ]) |
|
42 | ]) | |
43 | def test_simple_get(self, urlname, app): |
|
43 | def test_simple_get(self, urlname, app): | |
44 | app.get(url(urlname, repo_name=HG_REPO)) |
|
44 | app.get(url(urlname, repo_name=HG_REPO)) | |
45 |
|
45 | |||
46 | @pytest.mark.parametrize('setting_name, setting_backends', [ |
|
46 | @pytest.mark.parametrize('setting_name, setting_backends', [ | |
47 | ('hg_use_rebase_for_merging', ['hg']), |
|
47 | ('hg_use_rebase_for_merging', ['hg']), | |
48 | ]) |
|
48 | ]) | |
49 | def test_labs_settings_visible_if_enabled( |
|
49 | def test_labs_settings_visible_if_enabled( | |
50 | self, setting_name, setting_backends, backend): |
|
50 | self, setting_name, setting_backends, backend): | |
51 | if backend.alias not in setting_backends: |
|
51 | if backend.alias not in setting_backends: | |
52 | pytest.skip('Setting not available for backend {}'.format(backend)) |
|
52 | pytest.skip('Setting not available for backend {}'.format(backend)) | |
53 |
|
53 | |||
54 | vcs_settings_url = url( |
|
54 | vcs_settings_url = url( | |
55 | 'repo_vcs_settings', repo_name=backend.repo.repo_name) |
|
55 | 'repo_vcs_settings', repo_name=backend.repo.repo_name) | |
56 |
|
56 | |||
57 | with mock.patch.dict( |
|
57 | with mock.patch.dict( | |
58 | rhodecode.CONFIG, {'labs_settings_active': 'true'}): |
|
58 | rhodecode.CONFIG, {'labs_settings_active': 'true'}): | |
59 | response = self.app.get(vcs_settings_url) |
|
59 | response = self.app.get(vcs_settings_url) | |
60 |
|
60 | |||
61 | assertr = AssertResponse(response) |
|
61 | assertr = AssertResponse(response) | |
62 | assertr.one_element_exists('#rhodecode_{}'.format(setting_name)) |
|
62 | assertr.one_element_exists('#rhodecode_{}'.format(setting_name)) | |
63 |
|
63 | |||
64 | @pytest.mark.parametrize('setting_name, setting_backends', [ |
|
64 | @pytest.mark.parametrize('setting_name, setting_backends', [ | |
65 | ('hg_use_rebase_for_merging', ['hg']), |
|
65 | ('hg_use_rebase_for_merging', ['hg']), | |
66 | ]) |
|
66 | ]) | |
67 | def test_labs_settings_not_visible_if_disabled( |
|
67 | def test_labs_settings_not_visible_if_disabled( | |
68 | self, setting_name, setting_backends, backend): |
|
68 | self, setting_name, setting_backends, backend): | |
69 | if backend.alias not in setting_backends: |
|
69 | if backend.alias not in setting_backends: | |
70 | pytest.skip('Setting not available for backend {}'.format(backend)) |
|
70 | pytest.skip('Setting not available for backend {}'.format(backend)) | |
71 |
|
71 | |||
72 | vcs_settings_url = url( |
|
72 | vcs_settings_url = url( | |
73 | 'repo_vcs_settings', repo_name=backend.repo.repo_name) |
|
73 | 'repo_vcs_settings', repo_name=backend.repo.repo_name) | |
74 |
|
74 | |||
75 | with mock.patch.dict( |
|
75 | with mock.patch.dict( | |
76 | rhodecode.CONFIG, {'labs_settings_active': 'false'}): |
|
76 | rhodecode.CONFIG, {'labs_settings_active': 'false'}): | |
77 | response = self.app.get(vcs_settings_url) |
|
77 | response = self.app.get(vcs_settings_url) | |
78 |
|
78 | |||
79 | assertr = AssertResponse(response) |
|
79 | assertr = AssertResponse(response) | |
80 | assertr.no_element_exists('#rhodecode_{}'.format(setting_name)) |
|
80 | assertr.no_element_exists('#rhodecode_{}'.format(setting_name)) | |
81 |
|
81 | |||
82 | @pytest.mark.parametrize('setting_name, setting_backends', [ |
|
82 | @pytest.mark.parametrize('setting_name, setting_backends', [ | |
83 | ('hg_use_rebase_for_merging', ['hg']), |
|
83 | ('hg_use_rebase_for_merging', ['hg']), | |
84 | ]) |
|
84 | ]) | |
85 | def test_update_boolean_settings( |
|
85 | def test_update_boolean_settings( | |
86 | self, csrf_token, setting_name, setting_backends, backend): |
|
86 | self, csrf_token, setting_name, setting_backends, backend): | |
87 | if backend.alias not in setting_backends: |
|
87 | if backend.alias not in setting_backends: | |
88 | pytest.skip('Setting not available for backend {}'.format(backend)) |
|
88 | pytest.skip('Setting not available for backend {}'.format(backend)) | |
89 |
|
89 | |||
90 | settings_model = SettingsModel(repo=backend.repo) |
|
90 | repo = backend.create_repo() | |
|
91 | ||||
|
92 | settings_model = SettingsModel(repo=repo) | |||
91 | vcs_settings_url = url( |
|
93 | vcs_settings_url = url( | |
92 |
'repo_vcs_settings', repo_name= |
|
94 | 'repo_vcs_settings', repo_name=repo.repo_name) | |
93 |
|
95 | |||
94 | self.app.post( |
|
96 | self.app.post( | |
95 | vcs_settings_url, |
|
97 | vcs_settings_url, | |
96 | params={ |
|
98 | params={ | |
|
99 | 'inherit_global_settings': False, | |||
97 | 'new_svn_branch': 'dummy-value-for-testing', |
|
100 | 'new_svn_branch': 'dummy-value-for-testing', | |
98 | 'new_svn_tag': 'dummy-value-for-testing', |
|
101 | 'new_svn_tag': 'dummy-value-for-testing', | |
99 | 'rhodecode_{}'.format(setting_name): 'true', |
|
102 | 'rhodecode_{}'.format(setting_name): 'true', | |
100 | 'csrf_token': csrf_token, |
|
103 | 'csrf_token': csrf_token, | |
101 | }) |
|
104 | }) | |
102 | setting = settings_model.get_setting_by_name(setting_name) |
|
105 | setting = settings_model.get_setting_by_name(setting_name) | |
103 | assert setting.app_settings_value |
|
106 | assert setting.app_settings_value | |
104 |
|
107 | |||
105 | self.app.post( |
|
108 | self.app.post( | |
106 | vcs_settings_url, |
|
109 | vcs_settings_url, | |
107 | params={ |
|
110 | params={ | |
|
111 | 'inherit_global_settings': False, | |||
108 | 'new_svn_branch': 'dummy-value-for-testing', |
|
112 | 'new_svn_branch': 'dummy-value-for-testing', | |
109 | 'new_svn_tag': 'dummy-value-for-testing', |
|
113 | 'new_svn_tag': 'dummy-value-for-testing', | |
110 | 'rhodecode_{}'.format(setting_name): 'false', |
|
114 | 'rhodecode_{}'.format(setting_name): 'false', | |
111 | 'csrf_token': csrf_token, |
|
115 | 'csrf_token': csrf_token, | |
112 | }) |
|
116 | }) | |
113 | setting = settings_model.get_setting_by_name(setting_name) |
|
117 | setting = settings_model.get_setting_by_name(setting_name) | |
114 | assert not setting.app_settings_value |
|
118 | assert not setting.app_settings_value |
General Comments 0
You need to be logged in to leave comments.
Login now