##// 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
@@ -21,6 +21,8 b''
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
@@ -41,30 +43,72 b' class TestAdminRepoSettingsController:'
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 'rhodecode_hg_use_rebase_for_merging',
47 ('hg_use_rebase_for_merging', ['hg']),
46 ])
48 ])
47 def test_labs_settings_enabled_hg(self, setting_name):
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 'rhodecode_hg_use_rebase_for_merging',
65 ('hg_use_rebase_for_merging', ['hg']),
60 ])
66 ])
61 def test_labs_settings_disabled_hg(self, setting_name):
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