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