##// END OF EJS Templates
tests: Test the hg rebase setting on repo vcs setings page.
Martin Bornhold -
r370:f45845ad default
parent child Browse files
Show More
@@ -1,70 +1,114 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 import rhodecode
25 from rhodecode.model.settings import SettingsModel
24 26 from rhodecode.tests import url, HG_REPO
25 27 from rhodecode.tests.utils import AssertResponse
26 28
27 29
28 30 @pytest.mark.usefixtures('autologin_user', 'app')
29 31 class TestAdminRepoSettingsController:
30 32 @pytest.mark.parametrize('urlname', [
31 33 'edit_repo',
32 34 'edit_repo_perms',
33 35 'edit_repo_advanced',
34 36 'repo_vcs_settings',
35 37 'edit_repo_fields',
36 38 'repo_settings_issuetracker',
37 39 'edit_repo_caches',
38 40 'edit_repo_remote',
39 41 'edit_repo_statistics',
40 42 ])
41 43 def test_simple_get(self, urlname, app):
42 44 app.get(url(urlname, repo_name=HG_REPO))
43 45
44 @pytest.mark.parametrize('setting_name', [
45 'rhodecode_hg_use_rebase_for_merging',
46 @pytest.mark.parametrize('setting_name, setting_backends', [
47 ('hg_use_rebase_for_merging', ['hg']),
46 48 ])
47 def test_labs_settings_enabled_hg(self, setting_name):
48 import rhodecode
49 vcs_settings_url = url('repo_vcs_settings', repo_name=HG_REPO)
49 def test_labs_settings_visible_if_enabled(
50 self, setting_name, setting_backends, backend):
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 57 with mock.patch.dict(
52 58 rhodecode.CONFIG, {'labs_settings_active': 'true'}):
53 59 response = self.app.get(vcs_settings_url)
54 60
55 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', [
59 'rhodecode_hg_use_rebase_for_merging',
64 @pytest.mark.parametrize('setting_name, setting_backends', [
65 ('hg_use_rebase_for_merging', ['hg']),
60 66 ])
61 def test_labs_settings_disabled_hg(self, setting_name):
62 import rhodecode
63 vcs_settings_url = url('repo_vcs_settings', repo_name=HG_REPO)
67 def test_labs_settings_not_visible_if_disabled(
68 self, setting_name, setting_backends, backend):
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 75 with mock.patch.dict(
66 76 rhodecode.CONFIG, {'labs_settings_active': 'false'}):
67 77 response = self.app.get(vcs_settings_url)
68 78
69 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