##// END OF EJS Templates
testing: fixed test routes
super-admin -
r5175:0b2d4499 default
parent child Browse files
Show More
@@ -1,290 +1,319 b''
1 # Copyright (C) 2010-2023 RhodeCode GmbH
1 # Copyright (C) 2010-2023 RhodeCode GmbH
2 #
2 #
3 # This program is free software: you can redistribute it and/or modify
3 # This program is free software: you can redistribute it and/or modify
4 # it under the terms of the GNU Affero General Public License, version 3
4 # it under the terms of the GNU Affero General Public License, version 3
5 # (only), as published by the Free Software Foundation.
5 # (only), as published by the Free Software Foundation.
6 #
6 #
7 # This program is distributed in the hope that it will be useful,
7 # This program is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 # GNU General Public License for more details.
10 # GNU General Public License for more details.
11 #
11 #
12 # You should have received a copy of the GNU Affero General Public License
12 # You should have received a copy of the GNU Affero General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14 #
14 #
15 # This program is dual-licensed. If you wish to learn more about the
15 # This program is dual-licensed. If you wish to learn more about the
16 # RhodeCode Enterprise Edition, including its added features, Support services,
16 # RhodeCode Enterprise Edition, including its added features, Support services,
17 # and proprietary license terms, please see https://rhodecode.com/licenses/
17 # and proprietary license terms, please see https://rhodecode.com/licenses/
18
18
19
19
20 def get_url_defs():
20 def get_url_defs():
21 from rhodecode.apps._base import ADMIN_PREFIX
21 from rhodecode.apps._base import ADMIN_PREFIX
22
22
23 return {
23 return {
24 "home": "/",
24 "home": "/",
25 "main_page_repos_data": "/_home_repos",
25 "main_page_repos_data": "/_home_repos",
26 "main_page_repo_groups_data": "/_home_repo_groups",
26 "main_page_repo_groups_data": "/_home_repo_groups",
27 "repo_group_home": "/{repo_group_name}",
27 "repo_group_home": "/{repo_group_name}",
28 "user_autocomplete_data": "/_users",
28 "user_autocomplete_data": "/_users",
29 "user_group_autocomplete_data": "/_user_groups",
29 "user_group_autocomplete_data": "/_user_groups",
30 "repo_list_data": "/_repos",
30 "repo_list_data": "/_repos",
31 "goto_switcher_data": "/_goto_data",
31 "goto_switcher_data": "/_goto_data",
32 "admin_home": ADMIN_PREFIX + "",
32 "admin_home": ADMIN_PREFIX + "",
33 "admin_audit_logs": ADMIN_PREFIX + "/audit_logs",
33 "admin_audit_logs": ADMIN_PREFIX + "/audit_logs",
34 "admin_defaults_repositories": ADMIN_PREFIX + "/defaults/repositories",
34 "admin_defaults_repositories": ADMIN_PREFIX + "/defaults/repositories",
35 "admin_defaults_repositories_update": ADMIN_PREFIX + "/defaults/repositories/update",
35 "admin_defaults_repositories_update": ADMIN_PREFIX
36 + "/defaults/repositories/update",
36 "search": ADMIN_PREFIX + "/search",
37 "search": ADMIN_PREFIX + "/search",
37 "search_repo": "/{repo_name}/search",
38 "search_repo": "/{repo_name}/search",
38 "my_account_auth_tokens": ADMIN_PREFIX + "/my_account/auth_tokens",
39 "my_account_auth_tokens": ADMIN_PREFIX + "/my_account/auth_tokens",
39 "my_account_auth_tokens_add": ADMIN_PREFIX + "/my_account/auth_tokens/new",
40 "my_account_auth_tokens_add": ADMIN_PREFIX + "/my_account/auth_tokens/new",
40 "my_account_auth_tokens_delete": ADMIN_PREFIX + "/my_account/auth_tokens/delete",
41 "my_account_auth_tokens_delete": ADMIN_PREFIX
42 + "/my_account/auth_tokens/delete",
41 "repos": ADMIN_PREFIX + "/repos",
43 "repos": ADMIN_PREFIX + "/repos",
42 "repos_data": ADMIN_PREFIX + "/repos_data",
44 "repos_data": ADMIN_PREFIX + "/repos_data",
43 "repo_groups": ADMIN_PREFIX + "/repo_groups",
45 "repo_groups": ADMIN_PREFIX + "/repo_groups",
44 "repo_groups_data": ADMIN_PREFIX + "/repo_groups_data",
46 "repo_groups_data": ADMIN_PREFIX + "/repo_groups_data",
45 "user_groups": ADMIN_PREFIX + "/user_groups",
47 "user_groups": ADMIN_PREFIX + "/user_groups",
46 "user_groups_data": ADMIN_PREFIX + "/user_groups_data",
48 "user_groups_data": ADMIN_PREFIX + "/user_groups_data",
47 "user_profile": "/_profiles/{username}",
49 "user_profile": "/_profiles/{username}",
48 "profile_user_group": "/_profile_user_group/{user_group_name}",
50 "profile_user_group": "/_profile_user_group/{user_group_name}",
49 "repo_summary": "/{repo_name}",
51 "repo_summary": "/{repo_name}",
50 "repo_creating_check": "/{repo_name}/repo_creating_check",
52 "repo_creating_check": "/{repo_name}/repo_creating_check",
51 "edit_repo": "/{repo_name}/settings",
53 "edit_repo": "/{repo_name}/settings",
52 "edit_repo_vcs": "/{repo_name}/settings/vcs",
54 "edit_repo_vcs": "/{repo_name}/settings/vcs",
53 "edit_repo_vcs_update": "/{repo_name}/settings/vcs/update",
55 "edit_repo_vcs_update": "/{repo_name}/settings/vcs/update",
54 "edit_repo_vcs_svn_pattern_delete": "/{repo_name}/settings/vcs/svn_pattern/delete",
56 "edit_repo_vcs_svn_pattern_delete": "/{repo_name}/settings/vcs/svn_pattern/delete",
55 "repo_archivefile": "/{repo_name}/archive/{fname}",
57 "repo_archivefile": "/{repo_name}/archive/{fname}",
56 "repo_files_diff": "/{repo_name}/diff/{f_path}",
58 "repo_files_diff": "/{repo_name}/diff/{f_path}",
57 "repo_files_diff_2way_redirect": "/{repo_name}/diff-2way/{f_path}",
59 "repo_files_diff_2way_redirect": "/{repo_name}/diff-2way/{f_path}",
58 "repo_files": "/{repo_name}/files/{commit_id}/{f_path}",
60 "repo_files": "/{repo_name}/files/{commit_id}/{f_path}",
59 "repo_files:default_path": "/{repo_name}/files/{commit_id}/",
61 "repo_files:default_path": "/{repo_name}/files/{commit_id}/",
60 "repo_files:default_commit": "/{repo_name}/files",
62 "repo_files:default_commit": "/{repo_name}/files",
61 "repo_files:rendered": "/{repo_name}/render/{commit_id}/{f_path}",
63 "repo_files:rendered": "/{repo_name}/render/{commit_id}/{f_path}",
62 "repo_files:annotated": "/{repo_name}/annotate/{commit_id}/{f_path}",
64 "repo_files:annotated": "/{repo_name}/annotate/{commit_id}/{f_path}",
63 "repo_files:annotated_previous": "/{repo_name}/annotate-previous/{commit_id}/{f_path}",
65 "repo_files:annotated_previous": "/{repo_name}/annotate-previous/{commit_id}/{f_path}",
64 "repo_files_nodelist": "/{repo_name}/nodelist/{commit_id}/{f_path}",
66 "repo_files_nodelist": "/{repo_name}/nodelist/{commit_id}/{f_path}",
65 "repo_file_raw": "/{repo_name}/raw/{commit_id}/{f_path}",
67 "repo_file_raw": "/{repo_name}/raw/{commit_id}/{f_path}",
66 "repo_file_download": "/{repo_name}/download/{commit_id}/{f_path}",
68 "repo_file_download": "/{repo_name}/download/{commit_id}/{f_path}",
67 "repo_file_history": "/{repo_name}/history/{commit_id}/{f_path}",
69 "repo_file_history": "/{repo_name}/history/{commit_id}/{f_path}",
68 "repo_file_authors": "/{repo_name}/authors/{commit_id}/{f_path}",
70 "repo_file_authors": "/{repo_name}/authors/{commit_id}/{f_path}",
69 "repo_files_remove_file": "/{repo_name}/remove_file/{commit_id}/{f_path}",
71 "repo_files_remove_file": "/{repo_name}/remove_file/{commit_id}/{f_path}",
70 "repo_files_delete_file": "/{repo_name}/delete_file/{commit_id}/{f_path}",
72 "repo_files_delete_file": "/{repo_name}/delete_file/{commit_id}/{f_path}",
71 "repo_files_edit_file": "/{repo_name}/edit_file/{commit_id}/{f_path}",
73 "repo_files_edit_file": "/{repo_name}/edit_file/{commit_id}/{f_path}",
72 "repo_files_update_file": "/{repo_name}/update_file/{commit_id}/{f_path}",
74 "repo_files_update_file": "/{repo_name}/update_file/{commit_id}/{f_path}",
73 "repo_files_add_file": "/{repo_name}/add_file/{commit_id}/{f_path}",
75 "repo_files_add_file": "/{repo_name}/add_file/{commit_id}/{f_path}",
74 "repo_files_upload_file": "/{repo_name}/upload_file/{commit_id}/{f_path}",
76 "repo_files_upload_file": "/{repo_name}/upload_file/{commit_id}/{f_path}",
75 "repo_files_create_file": "/{repo_name}/create_file/{commit_id}/{f_path}",
77 "repo_files_create_file": "/{repo_name}/create_file/{commit_id}/{f_path}",
76 "repo_nodetree_full": "/{repo_name}/nodetree_full/{commit_id}/{f_path}",
78 "repo_nodetree_full": "/{repo_name}/nodetree_full/{commit_id}/{f_path}",
77 "repo_nodetree_full:default_path": "/{repo_name}/nodetree_full/{commit_id}/",
79 "repo_nodetree_full:default_path": "/{repo_name}/nodetree_full/{commit_id}/",
78 "journal": ADMIN_PREFIX + "/journal",
80 "journal": ADMIN_PREFIX + "/journal",
79 "journal_rss": ADMIN_PREFIX + "/journal/rss",
81 "journal_rss": ADMIN_PREFIX + "/journal/rss",
80 "journal_atom": ADMIN_PREFIX + "/journal/atom",
82 "journal_atom": ADMIN_PREFIX + "/journal/atom",
81 "journal_public": ADMIN_PREFIX + "/public_journal",
83 "journal_public": ADMIN_PREFIX + "/public_journal",
82 "journal_public_atom": ADMIN_PREFIX + "/public_journal/atom",
84 "journal_public_atom": ADMIN_PREFIX + "/public_journal/atom",
83 "journal_public_atom_old": ADMIN_PREFIX + "/public_journal_atom",
85 "journal_public_atom_old": ADMIN_PREFIX + "/public_journal_atom",
84 "journal_public_rss": ADMIN_PREFIX + "/public_journal/rss",
86 "journal_public_rss": ADMIN_PREFIX + "/public_journal/rss",
85 "journal_public_rss_old": ADMIN_PREFIX + "/public_journal_rss",
87 "journal_public_rss_old": ADMIN_PREFIX + "/public_journal_rss",
86 "toggle_following": ADMIN_PREFIX + "/toggle_following",
88 "toggle_following": ADMIN_PREFIX + "/toggle_following",
87 "upload_file": "/_file_store/upload",
89 "upload_file": "/_file_store/upload",
88 "download_file": "/_file_store/download/{fid}",
90 "download_file": "/_file_store/download/{fid}",
89 "download_file_by_token": "/_file_store/token-download/{_auth_token}/{fid}",
91 "download_file_by_token": "/_file_store/token-download/{_auth_token}/{fid}",
90 "gists_show": ADMIN_PREFIX + "/gists",
92 "gists_show": ADMIN_PREFIX + "/gists",
91 "gists_new": ADMIN_PREFIX + "/gists/new",
93 "gists_new": ADMIN_PREFIX + "/gists/new",
92 "gists_create": ADMIN_PREFIX + "/gists/create",
94 "gists_create": ADMIN_PREFIX + "/gists/create",
93 "gist_show": ADMIN_PREFIX + "/gists/{gist_id}",
95 "gist_show": ADMIN_PREFIX + "/gists/{gist_id}",
94 "gist_delete": ADMIN_PREFIX + "/gists/{gist_id}/delete",
96 "gist_delete": ADMIN_PREFIX + "/gists/{gist_id}/delete",
95 "gist_edit": ADMIN_PREFIX + "/gists/{gist_id}/edit",
97 "gist_edit": ADMIN_PREFIX + "/gists/{gist_id}/edit",
96 "gist_edit_check_revision": ADMIN_PREFIX + "/gists/{gist_id}/edit/check_revision",
98 "gist_edit_check_revision": ADMIN_PREFIX
99 + "/gists/{gist_id}/edit/check_revision",
97 "gist_update": ADMIN_PREFIX + "/gists/{gist_id}/update",
100 "gist_update": ADMIN_PREFIX + "/gists/{gist_id}/update",
98 "gist_show_rev": ADMIN_PREFIX + "/gists/{gist_id}/rev/{revision}",
101 "gist_show_rev": ADMIN_PREFIX + "/gists/{gist_id}/rev/{revision}",
99 "gist_show_formatted": ADMIN_PREFIX + "/gists/{gist_id}/rev/{revision}/{format}",
102 "gist_show_formatted": ADMIN_PREFIX
100 "gist_show_formatted_path": ADMIN_PREFIX + "/gists/{gist_id}/rev/{revision}/{format}/{f_path}",
103 + "/gists/{gist_id}/rev/{revision}/{format}",
104 "gist_show_formatted_path": ADMIN_PREFIX
105 + "/gists/{gist_id}/rev/{revision}/{format}/{f_path}",
101 "login": ADMIN_PREFIX + "/login",
106 "login": ADMIN_PREFIX + "/login",
102 "logout": ADMIN_PREFIX + "/logout",
107 "logout": ADMIN_PREFIX + "/logout",
103 "register": ADMIN_PREFIX + "/register",
108 "register": ADMIN_PREFIX + "/register",
104 "reset_password": ADMIN_PREFIX + "/password_reset",
109 "reset_password": ADMIN_PREFIX + "/password_reset",
105 "reset_password_confirmation": ADMIN_PREFIX + "/password_reset_confirmation",
110 "reset_password_confirmation": ADMIN_PREFIX + "/password_reset_confirmation",
106 "admin_permissions_application": ADMIN_PREFIX + "/permissions/application",
111 "admin_permissions_application": ADMIN_PREFIX + "/permissions/application",
107 "admin_permissions_application_update": ADMIN_PREFIX + "/permissions/application/update",
112 "admin_permissions_application_update": ADMIN_PREFIX
113 + "/permissions/application/update",
108 "repo_commit_raw": "/{repo_name}/changeset-diff/{commit_id}",
114 "repo_commit_raw": "/{repo_name}/changeset-diff/{commit_id}",
109 "user_group_members_data": ADMIN_PREFIX + "/user_groups/{user_group_id}/members",
115 "user_group_members_data": ADMIN_PREFIX
116 + "/user_groups/{user_group_id}/members",
110 "user_groups_new": ADMIN_PREFIX + "/user_groups/new",
117 "user_groups_new": ADMIN_PREFIX + "/user_groups/new",
111 "user_groups_create": ADMIN_PREFIX + "/user_groups/create",
118 "user_groups_create": ADMIN_PREFIX + "/user_groups/create",
112 "edit_user_group": ADMIN_PREFIX + "/user_groups/{user_group_id}/edit",
119 "edit_user_group": ADMIN_PREFIX + "/user_groups/{user_group_id}/edit",
113 "edit_user_group_advanced_sync": ADMIN_PREFIX + "/user_groups/{user_group_id}/edit/advanced/sync",
120 "edit_user_group_advanced_sync": ADMIN_PREFIX
114 "edit_user_group_global_perms_update": ADMIN_PREFIX + "/user_groups/{user_group_id}/edit/global_permissions/update",
121 + "/user_groups/{user_group_id}/edit/advanced/sync",
122 "edit_user_group_global_perms_update": ADMIN_PREFIX
123 + "/user_groups/{user_group_id}/edit/global_permissions/update",
115 "user_groups_update": ADMIN_PREFIX + "/user_groups/{user_group_id}/update",
124 "user_groups_update": ADMIN_PREFIX + "/user_groups/{user_group_id}/update",
116 "user_groups_delete": ADMIN_PREFIX + "/user_groups/{user_group_id}/delete",
125 "user_groups_delete": ADMIN_PREFIX + "/user_groups/{user_group_id}/delete",
117 "edit_user_group_perms": ADMIN_PREFIX + "/user_groups/{user_group_id}/edit/permissions",
126 "edit_user_group_perms": ADMIN_PREFIX
118 "edit_user_group_perms_update": ADMIN_PREFIX + "/user_groups/{user_group_id}/edit/permissions/update",
127 + "/user_groups/{user_group_id}/edit/permissions",
128 "edit_user_group_perms_update": ADMIN_PREFIX
129 + "/user_groups/{user_group_id}/edit/permissions/update",
119 "edit_repo_group": "/{repo_group_name}/_edit",
130 "edit_repo_group": "/{repo_group_name}/_edit",
120 "edit_repo_group_perms": "/{repo_group_name:}/_settings/permissions",
131 "edit_repo_group_perms": "/{repo_group_name:}/_settings/permissions",
121 "edit_repo_group_perms_update": "/{repo_group_name}/_settings/permissions/update",
132 "edit_repo_group_perms_update": "/{repo_group_name}/_settings/permissions/update",
122 "edit_repo_group_advanced": "/{repo_group_name}/_settings/advanced",
133 "edit_repo_group_advanced": "/{repo_group_name}/_settings/advanced",
123 "edit_repo_group_advanced_delete": "/{repo_group_name}/_settings/advanced/delete",
134 "edit_repo_group_advanced_delete": "/{repo_group_name}/_settings/advanced/delete",
124 "edit_user_ssh_keys": ADMIN_PREFIX + "/users/{user_id}/edit/ssh_keys",
135 "edit_user_ssh_keys": ADMIN_PREFIX + "/users/{user_id}/edit/ssh_keys",
125 "edit_user_ssh_keys_generate_keypair": ADMIN_PREFIX + "/users/{user_id}/edit/ssh_keys/generate",
136 "edit_user_ssh_keys_generate_keypair": ADMIN_PREFIX
137 + "/users/{user_id}/edit/ssh_keys/generate",
126 "edit_user_ssh_keys_add": ADMIN_PREFIX + "/users/{user_id}/edit/ssh_keys/new",
138 "edit_user_ssh_keys_add": ADMIN_PREFIX + "/users/{user_id}/edit/ssh_keys/new",
127 "edit_user_ssh_keys_delete": ADMIN_PREFIX + "/users/{user_id}/edit/ssh_keys/delete",
139 "edit_user_ssh_keys_delete": ADMIN_PREFIX
140 + "/users/{user_id}/edit/ssh_keys/delete",
128 "users": ADMIN_PREFIX + "/users",
141 "users": ADMIN_PREFIX + "/users",
129 "users_data": ADMIN_PREFIX + "/users_data",
142 "users_data": ADMIN_PREFIX + "/users_data",
130 "users_create": ADMIN_PREFIX + "/users/create",
143 "users_create": ADMIN_PREFIX + "/users/create",
131 "users_new": ADMIN_PREFIX + "/users/new",
144 "users_new": ADMIN_PREFIX + "/users/new",
132 "user_edit": ADMIN_PREFIX + "/users/{user_id}/edit",
145 "user_edit": ADMIN_PREFIX + "/users/{user_id}/edit",
133 "user_edit_advanced": ADMIN_PREFIX + "/users/{user_id}/edit/advanced",
146 "user_edit_advanced": ADMIN_PREFIX + "/users/{user_id}/edit/advanced",
134 "user_edit_global_perms": ADMIN_PREFIX + "/users/{user_id}/edit/global_permissions",
147 "user_edit_global_perms": ADMIN_PREFIX
135 "user_edit_global_perms_update": ADMIN_PREFIX + "/users/{user_id}/edit/global_permissions/update",
148 + "/users/{user_id}/edit/global_permissions",
149 "user_edit_global_perms_update": ADMIN_PREFIX
150 + "/users/{user_id}/edit/global_permissions/update",
136 "user_update": ADMIN_PREFIX + "/users/{user_id}/update",
151 "user_update": ADMIN_PREFIX + "/users/{user_id}/update",
137 "user_delete": ADMIN_PREFIX + "/users/{user_id}/delete",
152 "user_delete": ADMIN_PREFIX + "/users/{user_id}/delete",
138 "user_create_personal_repo_group": ADMIN_PREFIX + "/users/{user_id}/create_repo_group",
153 "user_create_personal_repo_group": ADMIN_PREFIX
154 + "/users/{user_id}/create_repo_group",
139 "edit_user_auth_tokens": ADMIN_PREFIX + "/users/{user_id}/edit/auth_tokens",
155 "edit_user_auth_tokens": ADMIN_PREFIX + "/users/{user_id}/edit/auth_tokens",
140 "edit_user_auth_tokens_add": ADMIN_PREFIX + "/users/{user_id}/edit/auth_tokens/new",
156 "edit_user_auth_tokens_add": ADMIN_PREFIX
141 "edit_user_auth_tokens_delete": ADMIN_PREFIX + "/users/{user_id}/edit/auth_tokens/delete",
157 + "/users/{user_id}/edit/auth_tokens/new",
158 "edit_user_auth_tokens_delete": ADMIN_PREFIX
159 + "/users/{user_id}/edit/auth_tokens/delete",
142 "edit_user_emails": ADMIN_PREFIX + "/users/{user_id}/edit/emails",
160 "edit_user_emails": ADMIN_PREFIX + "/users/{user_id}/edit/emails",
143 "edit_user_emails_add": ADMIN_PREFIX + "/users/{user_id}/edit/emails/new",
161 "edit_user_emails_add": ADMIN_PREFIX + "/users/{user_id}/edit/emails/new",
144 "edit_user_emails_delete": ADMIN_PREFIX + "/users/{user_id}/edit/emails/delete",
162 "edit_user_emails_delete": ADMIN_PREFIX + "/users/{user_id}/edit/emails/delete",
145 "edit_user_ips": ADMIN_PREFIX + "/users/{user_id}/edit/ips",
163 "edit_user_ips": ADMIN_PREFIX + "/users/{user_id}/edit/ips",
146 "edit_user_ips_add": ADMIN_PREFIX + "/users/{user_id}/edit/ips/new",
164 "edit_user_ips_add": ADMIN_PREFIX + "/users/{user_id}/edit/ips/new",
147 "edit_user_ips_delete": ADMIN_PREFIX + "/users/{user_id}/edit/ips/delete",
165 "edit_user_ips_delete": ADMIN_PREFIX + "/users/{user_id}/edit/ips/delete",
148 "edit_user_perms_summary": ADMIN_PREFIX + "/users/{user_id}/edit/permissions_summary",
166 "edit_user_perms_summary": ADMIN_PREFIX
149 "edit_user_perms_summary_json": ADMIN_PREFIX + "/users/{user_id}/edit/permissions_summary/json",
167 + "/users/{user_id}/edit/permissions_summary",
168 "edit_user_perms_summary_json": ADMIN_PREFIX
169 + "/users/{user_id}/edit/permissions_summary/json",
150 "edit_user_audit_logs": ADMIN_PREFIX + "/users/{user_id}/edit/audit",
170 "edit_user_audit_logs": ADMIN_PREFIX + "/users/{user_id}/edit/audit",
151 "edit_user_audit_logs_download": ADMIN_PREFIX + "/users/{user_id}/edit/audit/download",
171 "edit_user_audit_logs_download": ADMIN_PREFIX
172 + "/users/{user_id}/edit/audit/download",
152 "admin_settings": ADMIN_PREFIX + "/settings",
173 "admin_settings": ADMIN_PREFIX + "/settings",
153 "admin_settings_update": ADMIN_PREFIX + "/settings/update",
174 "admin_settings_update": ADMIN_PREFIX + "/settings/update",
154 "admin_settings_global": ADMIN_PREFIX + "/settings/global",
175 "admin_settings_global": ADMIN_PREFIX + "/settings/global",
155 "admin_settings_global_update": ADMIN_PREFIX + "/settings/global/update",
176 "admin_settings_global_update": ADMIN_PREFIX + "/settings/global/update",
156 "admin_settings_vcs": ADMIN_PREFIX + "/settings/vcs",
177 "admin_settings_vcs": ADMIN_PREFIX + "/settings/vcs",
157 "admin_settings_vcs_update": ADMIN_PREFIX + "/settings/vcs/update",
178 "admin_settings_vcs_update": ADMIN_PREFIX + "/settings/vcs/update",
158 "admin_settings_vcs_svn_pattern_delete": ADMIN_PREFIX + "/settings/vcs/svn_pattern_delete",
179 "admin_settings_vcs_svn_pattern_delete": ADMIN_PREFIX
180 + "/settings/vcs/svn_pattern_delete",
159 "admin_settings_mapping": ADMIN_PREFIX + "/settings/mapping",
181 "admin_settings_mapping": ADMIN_PREFIX + "/settings/mapping",
160 "admin_settings_mapping_update": ADMIN_PREFIX + "/settings/mapping/update",
182 "admin_settings_mapping_update": ADMIN_PREFIX + "/settings/mapping/update",
161 "admin_settings_visual": ADMIN_PREFIX + "/settings/visual",
183 "admin_settings_visual": ADMIN_PREFIX + "/settings/visual",
162 "admin_settings_visual_update": ADMIN_PREFIX + "/settings/visual/update",
184 "admin_settings_visual_update": ADMIN_PREFIX + "/settings/visual/update",
163 "admin_settings_issuetracker": ADMIN_PREFIX + "/settings/issue-tracker",
185 "admin_settings_issuetracker": ADMIN_PREFIX + "/settings/issue-tracker",
164 "admin_settings_issuetracker_update": ADMIN_PREFIX + "/settings/issue-tracker/update",
186 "admin_settings_issuetracker_update": ADMIN_PREFIX
165 "admin_settings_issuetracker_test": ADMIN_PREFIX + "/settings/issue-tracker/test",
187 + "/settings/issue-tracker/update",
166 "admin_settings_issuetracker_delete": ADMIN_PREFIX + "/settings/issue-tracker/delete",
188 "admin_settings_issuetracker_test": ADMIN_PREFIX
189 + "/settings/issue-tracker/test",
190 "admin_settings_issuetracker_delete": ADMIN_PREFIX
191 + "/settings/issue-tracker/delete",
167 "admin_settings_email": ADMIN_PREFIX + "/settings/email",
192 "admin_settings_email": ADMIN_PREFIX + "/settings/email",
168 "admin_settings_email_update": ADMIN_PREFIX + "/settings/email/update",
193 "admin_settings_email_update": ADMIN_PREFIX + "/settings/email/update",
169 "admin_settings_hooks": ADMIN_PREFIX + "/settings/hooks",
194 "admin_settings_hooks": ADMIN_PREFIX + "/settings/hooks",
170 "admin_settings_hooks_update": ADMIN_PREFIX + "/settings/hooks/update",
195 "admin_settings_hooks_update": ADMIN_PREFIX + "/settings/hooks/update",
171 "admin_settings_hooks_delete": ADMIN_PREFIX + "/settings/hooks/delete",
196 "admin_settings_hooks_delete": ADMIN_PREFIX + "/settings/hooks/delete",
172 "admin_settings_search": ADMIN_PREFIX + "/settings/search",
197 "admin_settings_search": ADMIN_PREFIX + "/settings/search",
173 "admin_settings_labs": ADMIN_PREFIX + "/settings/labs",
198 "admin_settings_labs": ADMIN_PREFIX + "/settings/labs",
174 "admin_settings_labs_update": ADMIN_PREFIX + "/settings/labs/update",
199 "admin_settings_labs_update": ADMIN_PREFIX + "/settings/labs/update",
175 "admin_settings_sessions": ADMIN_PREFIX + "/settings/sessions",
200 "admin_settings_sessions": ADMIN_PREFIX + "/settings/sessions",
176 "admin_settings_sessions_cleanup": ADMIN_PREFIX + "/settings/sessions/cleanup",
201 "admin_settings_sessions_cleanup": ADMIN_PREFIX + "/settings/sessions/cleanup",
177 "admin_settings_system": ADMIN_PREFIX + "/settings/system",
202 "admin_settings_system": ADMIN_PREFIX + "/settings/system",
178 "admin_settings_system_update": ADMIN_PREFIX + "/settings/system/updates",
203 "admin_settings_system_update": ADMIN_PREFIX + "/settings/system/updates",
179 "admin_settings_open_source": ADMIN_PREFIX + "/settings/open_source",
204 "admin_settings_open_source": ADMIN_PREFIX + "/settings/open_source",
180 "repo_group_new": ADMIN_PREFIX + "/repo_group/new",
205 "repo_group_new": ADMIN_PREFIX + "/repo_group/new",
181 "repo_group_create": ADMIN_PREFIX + "/repo_group/create",
206 "repo_group_create": ADMIN_PREFIX + "/repo_group/create",
182 "repo_new": ADMIN_PREFIX + "/repos/new",
207 "repo_new": ADMIN_PREFIX + "/repos/new",
183 "repo_create": ADMIN_PREFIX + "/repos/create",
208 "repo_create": ADMIN_PREFIX + "/repos/create",
184 "admin_permissions_global": ADMIN_PREFIX + "/permissions/global",
209 "admin_permissions_global": ADMIN_PREFIX + "/permissions/global",
185 "admin_permissions_global_update": ADMIN_PREFIX + "/permissions/global/update",
210 "admin_permissions_global_update": ADMIN_PREFIX + "/permissions/global/update",
186 "admin_permissions_object": ADMIN_PREFIX + "/permissions/object",
211 "admin_permissions_object": ADMIN_PREFIX + "/permissions/object",
187 "admin_permissions_object_update": ADMIN_PREFIX + "/permissions/object/update",
212 "admin_permissions_object_update": ADMIN_PREFIX + "/permissions/object/update",
188 "admin_permissions_ips": ADMIN_PREFIX + "/permissions/ips",
213 "admin_permissions_ips": ADMIN_PREFIX + "/permissions/ips",
189 "admin_permissions_overview": ADMIN_PREFIX + "/permissions/overview",
214 "admin_permissions_overview": ADMIN_PREFIX + "/permissions/overview",
190 "admin_permissions_ssh_keys": ADMIN_PREFIX + "/permissions/ssh_keys",
215 "admin_permissions_ssh_keys": ADMIN_PREFIX + "/permissions/ssh_keys",
191 "admin_permissions_ssh_keys_data": ADMIN_PREFIX + "/permissions/ssh_keys/data",
216 "admin_permissions_ssh_keys_data": ADMIN_PREFIX + "/permissions/ssh_keys/data",
192 "admin_permissions_ssh_keys_update": ADMIN_PREFIX + "/permissions/ssh_keys/update",
217 "admin_permissions_ssh_keys_update": ADMIN_PREFIX
218 + "/permissions/ssh_keys/update",
193 "pullrequest_show": "/{repo_name}/pull-request/{pull_request_id}",
219 "pullrequest_show": "/{repo_name}/pull-request/{pull_request_id}",
194 "pull_requests_global": ADMIN_PREFIX + "/pull-request/{pull_request_id}",
220 "pull_requests_global": ADMIN_PREFIX + "/pull-request/{pull_request_id}",
195 "pull_requests_global_0": ADMIN_PREFIX + "/pull_requests/{pull_request_id}",
221 "pull_requests_global_0": ADMIN_PREFIX + "/pull_requests/{pull_request_id}",
196 "pull_requests_global_1": ADMIN_PREFIX + "/pull-requests/{pull_request_id}",
222 "pull_requests_global_1": ADMIN_PREFIX + "/pull-requests/{pull_request_id}",
197 "notifications_show_all": ADMIN_PREFIX + "/notifications",
223 "notifications_show_all": ADMIN_PREFIX + "/notifications",
198 "notifications_mark_all_read": ADMIN_PREFIX + "/notifications_mark_all_read",
224 "notifications_mark_all_read": ADMIN_PREFIX + "/notifications_mark_all_read",
199 "notifications_show": ADMIN_PREFIX + "/notifications/{notification_id}",
225 "notifications_show": ADMIN_PREFIX + "/notifications/{notification_id}",
200 "notifications_update": ADMIN_PREFIX + "/notifications/{notification_id}/update",
226 "notifications_update": ADMIN_PREFIX
201 "notifications_delete": ADMIN_PREFIX + "/notifications/{notification_id}/delete",
227 + "/notifications/{notification_id}/update",
228 "notifications_delete": ADMIN_PREFIX
229 + "/notifications/{notification_id}/delete",
202 "my_account": ADMIN_PREFIX + "/my_account/profile",
230 "my_account": ADMIN_PREFIX + "/my_account/profile",
203 "my_account_edit": ADMIN_PREFIX + "/my_account/edit",
231 "my_account_edit": ADMIN_PREFIX + "/my_account/edit",
204 "my_account_update": ADMIN_PREFIX + "/my_account/update",
232 "my_account_update": ADMIN_PREFIX + "/my_account/update",
205 "my_account_pullrequests": ADMIN_PREFIX + "/my_account/pull_requests",
233 "my_account_pullrequests": ADMIN_PREFIX + "/my_account/pull_requests",
206 "my_account_pullrequests_data": ADMIN_PREFIX + "/my_account/pull_requests/data",
234 "my_account_pullrequests_data": ADMIN_PREFIX + "/my_account/pull_requests/data",
207 "my_account_emails": ADMIN_PREFIX + "/my_account/emails",
235 "my_account_emails": ADMIN_PREFIX + "/my_account/emails",
208 "my_account_emails_add": ADMIN_PREFIX + "/my_account/emails/new",
236 "my_account_emails_add": ADMIN_PREFIX + "/my_account/emails/new",
209 "my_account_emails_delete": ADMIN_PREFIX + "/my_account/emails/delete",
237 "my_account_emails_delete": ADMIN_PREFIX + "/my_account/emails/delete",
210 "my_account_password": ADMIN_PREFIX + "/my_account/password",
238 "my_account_password": ADMIN_PREFIX + "/my_account/password",
211 "my_account_password_update": ADMIN_PREFIX + "/my_account/password/update",
239 "my_account_password_update": ADMIN_PREFIX + "/my_account/password/update",
212 "my_account_repos": ADMIN_PREFIX + "/my_account/repos",
240 "my_account_repos": ADMIN_PREFIX + "/my_account/repos",
213 "my_account_watched": ADMIN_PREFIX + "/my_account/watched",
241 "my_account_watched": ADMIN_PREFIX + "/my_account/watched",
214 "my_account_perms": ADMIN_PREFIX + "/my_account/perms",
242 "my_account_perms": ADMIN_PREFIX + "/my_account/perms",
215 "my_account_notifications": ADMIN_PREFIX + "/my_account/notifications",
243 "my_account_notifications": ADMIN_PREFIX + "/my_account/notifications",
216 "my_account_ssh_keys": ADMIN_PREFIX + "/my_account/ssh_keys",
244 "my_account_ssh_keys": ADMIN_PREFIX + "/my_account/ssh_keys",
217 "my_account_ssh_keys_generate": ADMIN_PREFIX + "/my_account/ssh_keys/generate",
245 "my_account_ssh_keys_generate": ADMIN_PREFIX + "/my_account/ssh_keys/generate",
218 "my_account_ssh_keys_add": ADMIN_PREFIX + "/my_account/ssh_keys/new",
246 "my_account_ssh_keys_add": ADMIN_PREFIX + "/my_account/ssh_keys/new",
219 "my_account_ssh_keys_delete": ADMIN_PREFIX + "/my_account/ssh_keys/delete",
247 "my_account_ssh_keys_delete": ADMIN_PREFIX + "/my_account/ssh_keys/delete",
220 "pullrequest_show_all": "/{repo_name}/pull-request",
248 "pullrequest_show_all": "/{repo_name}/pull-request",
221 "pullrequest_show_all_data": "/{repo_name}/pull-request-data",
249 "pullrequest_show_all_data": "/{repo_name}/pull-request-data",
222 "bookmarks_home": "/{repo_name}/bookmarks",
250 "bookmarks_home": "/{repo_name}/bookmarks",
223 "branches_home": "/{repo_name}/branches",
251 "branches_home": "/{repo_name}/branches",
224 "tags_home": "/{repo_name}/tags",
252 "tags_home": "/{repo_name}/tags",
225 "repo_changelog": "/{repo_name}/changelog",
253 "repo_changelog": "/{repo_name}/changelog",
226 "repo_commits": "/{repo_name}/commits",
254 "repo_commits": "/{repo_name}/commits",
227 "repo_commits_file": "/{repo_name}/commits/{commit_id}/{f_path}",
255 "repo_commits_file": "/{repo_name}/commits/{commit_id}/{f_path}",
228 "repo_commits_elements": "/{repo_name}/commits_elements",
256 "repo_commits_elements": "/{repo_name}/commits_elements",
229 "repo_commit": "/{repo_name}/changeset/{commit_id}",
257 "repo_commit": "/{repo_name}/changeset/{commit_id}",
230 "repo_commit_comment_create": "/{repo_name}/changeset/{commit_id}/comment/create",
258 "repo_commit_comment_create": "/{repo_name}/changeset/{commit_id}/comment/create",
231 "repo_commit_comment_preview": "/{repo_name}/changeset/{commit_id}/comment/preview",
259 "repo_commit_comment_preview": "/{repo_name}/changeset/{commit_id}/comment/preview",
232 "repo_commit_comment_delete": "/{repo_name}/changeset/{commit_id}/comment/{comment_id}/delete",
260 "repo_commit_comment_delete": "/{repo_name}/changeset/{commit_id}/comment/{comment_id}/delete",
233 "repo_commit_comment_edit": "/{repo_name}/changeset/{commit_id}/comment/{comment_id}/edit",
261 "repo_commit_comment_edit": "/{repo_name}/changeset/{commit_id}/comment/{comment_id}/edit",
234 "repo_commit_children": "/{repo_name}/changeset_children/{commit_id}",
262 "repo_commit_children": "/{repo_name}/changeset_children/{commit_id}",
235 "repo_commit_parents": "/{repo_name}/changeset_parents/{commit_id}",
263 "repo_commit_parents": "/{repo_name}/changeset_parents/{commit_id}",
236 "repo_commit_patch": "/{repo_name}/changeset-patch/{commit_id}",
264 "repo_commit_patch": "/{repo_name}/changeset-patch/{commit_id}",
237 "repo_commit_download": "/{repo_name}/changeset-download/{commit_id}",
265 "repo_commit_download": "/{repo_name}/changeset-download/{commit_id}",
238 "repo_commit_data": "/{repo_name}/changeset-data/{commit_id}",
266 "repo_commit_data": "/{repo_name}/changeset-data/{commit_id}",
239 "repo_compare": "/{repo_name}/compare/{source_ref_type}@{source_ref}...{target_ref_type}@{target_ref}",
267 "repo_compare": "/{repo_name}/compare/{source_ref_type}@{source_ref}...{target_ref_type}@{target_ref}",
240 "repo_compare_select": "/{repo_name}/compare",
268 "repo_compare_select": "/{repo_name}/compare",
241 "rss_feed_home": "/{repo_name}/feed-rss",
269 "rss_feed_home": "/{repo_name}/feed-rss",
242 "atom_feed_home": "/{repo_name}/feed-atom",
270 "atom_feed_home": "/{repo_name}/feed-atom",
243 "rss_feed_home_old": "/{repo_name}/feed/rss",
271 "rss_feed_home_old": "/{repo_name}/feed/rss",
244 "atom_feed_home_old": "/{repo_name}/feed/atom",
272 "atom_feed_home_old": "/{repo_name}/feed/atom",
245 "repo_fork_new": "/{repo_name}/fork",
273 "repo_fork_new": "/{repo_name}/fork",
246 "repo_fork_create": "/{repo_name}/fork/create",
274 "repo_fork_create": "/{repo_name}/fork/create",
247 "repo_forks_show_all": "/{repo_name}/forks",
275 "repo_forks_show_all": "/{repo_name}/forks",
248 "repo_forks_data": "/{repo_name}/forks/data",
276 "repo_forks_data": "/{repo_name}/forks/data",
249 "edit_repo_issuetracker": "/{repo_name}/settings/issue_trackers",
277 "edit_repo_issuetracker": "/{repo_name}/settings/issue_trackers",
250 "edit_repo_issuetracker_test": "/{repo_name}/settings/issue_trackers/test",
278 "edit_repo_issuetracker_test": "/{repo_name}/settings/issue_trackers/test",
251 "edit_repo_issuetracker_delete": "/{repo_name}/settings/issue_trackers/delete",
279 "edit_repo_issuetracker_delete": "/{repo_name}/settings/issue_trackers/delete",
252 "edit_repo_issuetracker_update": "/{repo_name}/settings/issue_trackers/update",
280 "edit_repo_issuetracker_update": "/{repo_name}/settings/issue_trackers/update",
253 "edit_repo_maintenance": "/{repo_name}/settings/maintenance",
281 "edit_repo_maintenance": "/{repo_name}/settings/maintenance",
254 "edit_repo_maintenance_execute": "/{repo_name}/settings/maintenance/execute",
282 "edit_repo_maintenance_execute": "/{repo_name}/settings/maintenance/execute",
255 "repo_changelog_file": "/{repo_name}/changelog/{commit_id}/{f_path}",
283 "repo_changelog_file": "/{repo_name}/changelog/{commit_id}/{f_path}",
256 "pullrequest_repo_refs": "/{repo_name}/pull-request/refs/{target_repo_name:.*?[^/]}",
284 "pullrequest_repo_refs": "/{repo_name}/pull-request/refs/{target_repo_name:.*?[^/]}",
257 "pullrequest_repo_targets": "/{repo_name}/pull-request/repo-destinations",
285 "pullrequest_repo_targets": "/{repo_name}/pull-request/repo-destinations",
258 "pullrequest_new": "/{repo_name}/pull-request/new",
286 "pullrequest_new": "/{repo_name}/pull-request/new",
259 "pullrequest_create": "/{repo_name}/pull-request/create",
287 "pullrequest_create": "/{repo_name}/pull-request/create",
260 "pullrequest_update": "/{repo_name}/pull-request/{pull_request_id}/update",
288 "pullrequest_update": "/{repo_name}/pull-request/{pull_request_id}/update",
261 "pullrequest_merge": "/{repo_name}/pull-request/{pull_request_id}/merge",
289 "pullrequest_merge": "/{repo_name}/pull-request/{pull_request_id}/merge",
262 "pullrequest_delete": "/{repo_name}/pull-request/{pull_request_id}/delete",
290 "pullrequest_delete": "/{repo_name}/pull-request/{pull_request_id}/delete",
263 "pullrequest_comment_create": "/{repo_name}/pull-request/{pull_request_id}/comment",
291 "pullrequest_comment_create": "/{repo_name}/pull-request/{pull_request_id}/comment",
264 "pullrequest_comment_delete": "/{repo_name}/pull-request/{pull_request_id}/comment/{comment_id}/delete",
292 "pullrequest_comment_delete": "/{repo_name}/pull-request/{pull_request_id}/comment/{comment_id}/delete",
265 "pullrequest_comment_edit": "/{repo_name}/pull-request/{pull_request_id}/comment/{comment_id}/edit",
293 "pullrequest_comment_edit": "/{repo_name}/pull-request/{pull_request_id}/comment/{comment_id}/edit",
266 "edit_repo_caches": "/{repo_name}/settings/caches",
294 "edit_repo_caches": "/{repo_name}/settings/caches",
267 "edit_repo_perms": "/{repo_name}/settings/permissions",
295 "edit_repo_perms": "/{repo_name}/settings/permissions",
268 "edit_repo_fields": "/{repo_name}/settings/fields",
296 "edit_repo_fields": "/{repo_name}/settings/fields",
269 "edit_repo_remote": "/{repo_name}/settings/remote",
297 "edit_repo_remote": "/{repo_name}/settings/remote",
270 "edit_repo_statistics": "/{repo_name}/settings/statistics",
298 "edit_repo_statistics": "/{repo_name}/settings/statistics",
271 "edit_repo_advanced": "/{repo_name}/settings/advanced",
299 "edit_repo_advanced": "/{repo_name}/settings/advanced",
272 "edit_repo_advanced_delete": "/{repo_name}/settings/advanced/delete",
300 "edit_repo_advanced_delete": "/{repo_name}/settings/advanced/delete",
273 "edit_repo_advanced_archive": "/{repo_name}/settings/advanced/archive",
301 "edit_repo_advanced_archive": "/{repo_name}/settings/advanced/archive",
274 "edit_repo_advanced_fork": "/{repo_name}/settings/advanced/fork",
302 "edit_repo_advanced_fork": "/{repo_name}/settings/advanced/fork",
275 "edit_repo_advanced_locking": "/{repo_name}/settings/advanced/locking",
303 "edit_repo_advanced_locking": "/{repo_name}/settings/advanced/locking",
276 "edit_repo_advanced_journal": "/{repo_name}/settings/advanced/journal",
304 "edit_repo_advanced_journal": "/{repo_name}/settings/advanced/journal",
277 "repo_stats": "/{repo_name}/repo_stats/{commit_id}",
305 "repo_stats": "/{repo_name}/repo_stats/{commit_id}",
278 "repo_refs_data": "/{repo_name}/refs-data",
306 "repo_refs_data": "/{repo_name}/refs-data",
279 "repo_refs_changelog_data": "/{repo_name}/refs-data-changelog"
307 "repo_refs_changelog_data": "/{repo_name}/refs-data-changelog",
308 "repo_artifacts_stream_store": "/_file_store/stream-upload",
280 }
309 }
281
310
282
311
283 def route_path(name, params=None, **kwargs):
312 def route_path(name, params=None, **kwargs):
284 import urllib.parse
313 import urllib.parse
285
314
286 base_url = get_url_defs()[name].format(**kwargs)
315 base_url = get_url_defs()[name].format(**kwargs)
287
316
288 if params:
317 if params:
289 base_url = f"{base_url}?{urllib.parse.urlencode(params)}"
318 base_url = f"{base_url}?{urllib.parse.urlencode(params)}"
290 return base_url
319 return base_url
@@ -1,560 +1,560 b''
1
1
2 # Copyright (C) 2010-2023 RhodeCode GmbH
2 # Copyright (C) 2010-2023 RhodeCode GmbH
3 #
3 #
4 # This program is free software: you can redistribute it and/or modify
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU Affero General Public License, version 3
5 # it under the terms of the GNU Affero General Public License, version 3
6 # (only), as published by the Free Software Foundation.
6 # (only), as published by the Free Software Foundation.
7 #
7 #
8 # This program is distributed in the hope that it will be useful,
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
11 # GNU General Public License for more details.
12 #
12 #
13 # You should have received a copy of the GNU Affero General Public License
13 # You should have received a copy of the GNU Affero General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 #
15 #
16 # This program is dual-licensed. If you wish to learn more about the
16 # This program is dual-licensed. If you wish to learn more about the
17 # RhodeCode Enterprise Edition, including its added features, Support services,
17 # RhodeCode Enterprise Edition, including its added features, Support services,
18 # and proprietary license terms, please see https://rhodecode.com/licenses/
18 # and proprietary license terms, please see https://rhodecode.com/licenses/
19
19
20 import datetime
20 import datetime
21 from urllib.error import URLError
21 from urllib.error import URLError
22
22
23 import mock
23 import mock
24 import pytest
24 import pytest
25
25
26 from rhodecode.lib.vcs import backends
26 from rhodecode.lib.vcs import backends
27 from rhodecode.lib.vcs.backends.base import (
27 from rhodecode.lib.vcs.backends.base import (
28 Config, BaseInMemoryCommit, Reference, MergeResponse, MergeFailureReason)
28 Config, BaseInMemoryCommit, Reference, MergeResponse, MergeFailureReason)
29 from rhodecode.lib.vcs.exceptions import VCSError, RepositoryError
29 from rhodecode.lib.vcs.exceptions import VCSError, RepositoryError
30 from rhodecode.lib.vcs.nodes import FileNode
30 from rhodecode.lib.vcs.nodes import FileNode
31 from rhodecode.tests.vcs.conftest import BackendTestMixin
31 from rhodecode.tests.vcs.conftest import BackendTestMixin
32 from rhodecode.tests import repo_id_generator
32 from rhodecode.tests import repo_id_generator
33
33
34
34
35 @pytest.mark.usefixtures("vcs_repository_support")
35 @pytest.mark.usefixtures("vcs_repository_support")
36 class TestRepositoryBase(BackendTestMixin):
36 class TestRepositoryBase(BackendTestMixin):
37 recreate_repo_per_test = False
37 recreate_repo_per_test = False
38
38
39 def test_init_accepts_unicode_path(self, tmpdir):
39 def test_init_accepts_unicode_path(self, tmpdir):
40 path = str(tmpdir.join(u'unicode Γ€'))
40 path = str(tmpdir.join(u'unicode Γ€'))
41 self.Backend(path, create=True)
41 self.Backend(path, create=True)
42
42
43 def test_init_accepts_str_path(self, tmpdir):
43 def test_init_accepts_str_path(self, tmpdir):
44 path = str(tmpdir.join('str Γ€'))
44 path = str(tmpdir.join('str Γ€'))
45 self.Backend(path, create=True)
45 self.Backend(path, create=True)
46
46
47 def test_init_fails_if_path_does_not_exist(self, tmpdir):
47 def test_init_fails_if_path_does_not_exist(self, tmpdir):
48 path = str(tmpdir.join('i-do-not-exist'))
48 path = str(tmpdir.join('i-do-not-exist'))
49 with pytest.raises(VCSError):
49 with pytest.raises(VCSError):
50 self.Backend(path)
50 self.Backend(path)
51
51
52 def test_init_fails_if_path_is_not_a_valid_repository(self, tmpdir):
52 def test_init_fails_if_path_is_not_a_valid_repository(self, tmpdir):
53 path = str(tmpdir.mkdir(u'unicode Γ€'))
53 path = str(tmpdir.mkdir(u'unicode Γ€'))
54 with pytest.raises(VCSError):
54 with pytest.raises(VCSError):
55 self.Backend(path)
55 self.Backend(path)
56
56
57 def test_has_commits_attribute(self):
57 def test_has_commits_attribute(self):
58 assert self.repo.commit_ids
58 assert self.repo.commit_ids
59
59
60 def test_name(self):
60 def test_name(self):
61 assert self.repo.name.startswith('vcs-test')
61 assert self.repo.name.startswith('vcs-test')
62
62
63 @pytest.mark.backends("hg", "git")
63 @pytest.mark.backends("hg", "git")
64 def test_has_default_branch_name(self):
64 def test_has_default_branch_name(self):
65 assert self.repo.DEFAULT_BRANCH_NAME is not None
65 assert self.repo.DEFAULT_BRANCH_NAME is not None
66
66
67 @pytest.mark.backends("svn")
67 @pytest.mark.backends("svn")
68 def test_has_no_default_branch_name(self):
68 def test_has_no_default_branch_name(self):
69 assert self.repo.DEFAULT_BRANCH_NAME is None
69 assert self.repo.DEFAULT_BRANCH_NAME is None
70
70
71 def test_has_empty_commit(self):
71 def test_has_empty_commit(self):
72 assert self.repo.EMPTY_COMMIT_ID is not None
72 assert self.repo.EMPTY_COMMIT_ID is not None
73 assert self.repo.EMPTY_COMMIT is not None
73 assert self.repo.EMPTY_COMMIT is not None
74
74
75 def test_empty_changeset_is_deprecated(self):
75 def test_empty_changeset_is_deprecated(self):
76 def get_empty_changeset(repo):
76 def get_empty_changeset(repo):
77 return repo.EMPTY_CHANGESET
77 return repo.EMPTY_CHANGESET
78 pytest.deprecated_call(get_empty_changeset, self.repo)
78 pytest.deprecated_call(get_empty_changeset, self.repo)
79
79
80 def test_bookmarks(self):
80 def test_bookmarks(self):
81 assert len(self.repo.bookmarks) == 0
81 assert len(self.repo.bookmarks) == 0
82
82
83 def test_check_url_on_path(self):
83 def test_check_url_on_path(self):
84 config = Config()
84 config = Config()
85 assert self.Backend.check_url(self.repo.path, config)
85 assert self.Backend.check_url(self.repo.path, config)
86
86
87 def test_check_url_on_remote_url(self):
87 def test_check_url_on_remote_url(self):
88 config = Config()
88 config = Config()
89 url = {
89 url = {
90 'hg': 'https://code.rhodecode.com/rhodecode-vcsserver',
90 'hg': 'https://code.rhodecode.com/rhodecode-vcsserver',
91 'svn': 'https://code.rhodecode.com/svn-doc',
91 'svn': 'https://code.rhodecode.com/svn-doc',
92 'git': 'https://code.rhodecode.com/appenlight',
92 'git': 'https://code.rhodecode.com/appenlight',
93 }[self.repo.alias]
93 }[self.repo.alias]
94
94
95 assert self.Backend.check_url(url, config)
95 assert self.Backend.check_url(url, config)
96
96
97 def test_check_url_invalid(self):
97 def test_check_url_invalid(self):
98 config = Config()
98 config = Config()
99 with pytest.raises(URLError):
99 with pytest.raises(URLError):
100 self.Backend.check_url(self.repo.path + "invalid", config)
100 self.Backend.check_url(self.repo.path + "invalid", config)
101
101
102 def test_get_contact(self):
102 def test_get_contact(self):
103 assert self.repo.contact
103 assert self.repo.contact
104
104
105 def test_get_description(self):
105 def test_get_description(self):
106 assert self.repo.description
106 assert self.repo.description
107
107
108 def test_get_hook_location(self):
108 def test_get_hook_location(self):
109 assert len(self.repo.get_hook_location()) != 0
109 assert len(self.repo.get_hook_location()) != 0
110
110
111 def test_last_change(self, local_dt_to_utc):
111 def test_last_change(self, local_dt_to_utc):
112 assert self.repo.last_change >= local_dt_to_utc(
112 assert self.repo.last_change >= local_dt_to_utc(
113 datetime.datetime(2010, 1, 1, 21, 0))
113 datetime.datetime(2010, 1, 1, 21, 0))
114
114
115 def test_last_change_in_empty_repository(self, vcsbackend, local_dt_to_utc):
115 def test_last_change_in_empty_repository(self, vcsbackend, local_dt_to_utc):
116 delta = datetime.timedelta(seconds=1)
116 delta = datetime.timedelta(seconds=1)
117
117
118 start = local_dt_to_utc(datetime.datetime.now())
118 start = local_dt_to_utc(datetime.datetime.now())
119 empty_repo = vcsbackend.create_repo()
119 empty_repo = vcsbackend.create_repo()
120 now = local_dt_to_utc(datetime.datetime.now())
120 now = local_dt_to_utc(datetime.datetime.now())
121 assert empty_repo.last_change >= start - delta
121 assert empty_repo.last_change >= start - delta
122 assert empty_repo.last_change <= now + delta
122 assert empty_repo.last_change <= now + delta
123
123
124 def test_repo_equality(self):
124 def test_repo_equality(self):
125 assert self.repo == self.repo
125 assert self.repo == self.repo
126
126
127 def test_repo_equality_broken_object(self):
127 def test_repo_equality_broken_object(self):
128 import copy
128 import copy
129 _repo = copy.copy(self.repo)
129 _repo = copy.copy(self.repo)
130 delattr(_repo, 'path')
130 delattr(_repo, 'path')
131 assert self.repo != _repo
131 assert self.repo != _repo
132
132
133 def test_repo_equality_other_object(self):
133 def test_repo_equality_other_object(self):
134 class dummy(object):
134 class dummy(object):
135 path = self.repo.path
135 path = self.repo.path
136 assert self.repo != dummy()
136 assert self.repo != dummy()
137
137
138 def test_get_commit_is_implemented(self):
138 def test_get_commit_is_implemented(self):
139 self.repo.get_commit()
139 self.repo.get_commit()
140
140
141 def test_get_commits_is_implemented(self):
141 def test_get_commits_is_implemented(self):
142 commit_iter = iter(self.repo.get_commits())
142 commit_iter = iter(self.repo.get_commits())
143 commit = next(commit_iter)
143 commit = next(commit_iter)
144 assert commit.idx == 0
144 assert commit.idx == 0
145
145
146 def test_supports_iteration(self):
146 def test_supports_iteration(self):
147 repo_iter = iter(self.repo)
147 repo_iter = iter(self.repo)
148 commit = next(repo_iter)
148 commit = next(repo_iter)
149 assert commit.idx == 0
149 assert commit.idx == 0
150
150
151 def test_in_memory_commit(self):
151 def test_in_memory_commit(self):
152 imc = self.repo.in_memory_commit
152 imc = self.repo.in_memory_commit
153 assert isinstance(imc, BaseInMemoryCommit)
153 assert isinstance(imc, BaseInMemoryCommit)
154
154
155 @pytest.mark.backends("hg")
155 @pytest.mark.backends("hg")
156 def test__get_url_unicode(self):
156 def test__get_url_unicode(self):
157 url = u'/home/repos/malmΓΆ'
157 url = u'/home/repos/malmΓΆ'
158 assert self.repo._get_url(url)
158 assert self.repo._get_url(url)
159
159
160
160
161 @pytest.mark.usefixtures("vcs_repository_support")
161 @pytest.mark.usefixtures("vcs_repository_support")
162 class TestDeprecatedRepositoryAPI(BackendTestMixin):
162 class TestDeprecatedRepositoryAPI(BackendTestMixin):
163 recreate_repo_per_test = False
163 recreate_repo_per_test = False
164
164
165 def test_revisions_is_deprecated(self):
165 def test_revisions_is_deprecated(self):
166 def get_revisions(repo):
166 def get_revisions(repo):
167 return repo.revisions
167 return repo.revisions
168 pytest.deprecated_call(get_revisions, self.repo)
168 pytest.deprecated_call(get_revisions, self.repo)
169
169
170 def test_get_changeset_is_deprecated(self):
170 def test_get_changeset_is_deprecated(self):
171 pytest.deprecated_call(self.repo.get_changeset)
171 pytest.deprecated_call(self.repo.get_changeset)
172
172
173 def test_get_changesets_is_deprecated(self):
173 def test_get_changesets_is_deprecated(self):
174 pytest.deprecated_call(self.repo.get_changesets)
174 pytest.deprecated_call(self.repo.get_changesets)
175
175
176 def test_in_memory_changeset_is_deprecated(self):
176 def test_in_memory_changeset_is_deprecated(self):
177 def get_imc(repo):
177 def get_imc(repo):
178 return repo.in_memory_changeset
178 return repo.in_memory_changeset
179 pytest.deprecated_call(get_imc, self.repo)
179 pytest.deprecated_call(get_imc, self.repo)
180
180
181
181
182 # TODO: these tests are incomplete, must check the resulting compare result for
182 # TODO: these tests are incomplete, must check the resulting compare result for
183 # correcteness
183 # correcteness
184 class TestRepositoryCompare:
184 class TestRepositoryCompare:
185
185
186 @pytest.mark.parametrize('merge', [True, False])
186 @pytest.mark.parametrize('merge', [True, False])
187 def test_compare_commits_of_same_repository(self, vcsbackend, merge):
187 def test_compare_commits_of_same_repository(self, vcsbackend, merge):
188 target_repo = vcsbackend.create_repo(number_of_commits=5)
188 target_repo = vcsbackend.create_repo(number_of_commits=5)
189 target_repo.compare(
189 target_repo.compare(
190 target_repo[1].raw_id, target_repo[3].raw_id, target_repo,
190 target_repo[1].raw_id, target_repo[3].raw_id, target_repo,
191 merge=merge)
191 merge=merge)
192
192
193 @pytest.mark.xfail_backends('svn')
193 @pytest.mark.xfail_backends('svn')
194 @pytest.mark.parametrize('merge', [True, False])
194 @pytest.mark.parametrize('merge', [True, False])
195 def test_compare_cloned_repositories(self, vcsbackend, merge):
195 def test_compare_cloned_repositories(self, vcsbackend, merge):
196 target_repo = vcsbackend.create_repo(number_of_commits=5)
196 target_repo = vcsbackend.create_repo(number_of_commits=5)
197 source_repo = vcsbackend.clone_repo(target_repo)
197 source_repo = vcsbackend.clone_repo(target_repo)
198 assert target_repo != source_repo
198 assert target_repo != source_repo
199
199
200 vcsbackend.add_file(source_repo, b'newfile', b'somecontent')
200 vcsbackend.add_file(source_repo, b'newfile', b'somecontent')
201 source_commit = source_repo.get_commit()
201 source_commit = source_repo.get_commit()
202
202
203 target_repo.compare(
203 target_repo.compare(
204 target_repo[1].raw_id, source_repo[3].raw_id, source_repo,
204 target_repo[1].raw_id, source_repo[3].raw_id, source_repo,
205 merge=merge)
205 merge=merge)
206
206
207 @pytest.mark.xfail_backends('svn')
207 @pytest.mark.xfail_backends('svn')
208 @pytest.mark.parametrize('merge', [True, False])
208 @pytest.mark.parametrize('merge', [True, False])
209 def test_compare_unrelated_repositories(self, vcsbackend, merge):
209 def test_compare_unrelated_repositories(self, vcsbackend, merge):
210 orig = vcsbackend.create_repo(number_of_commits=5)
210 orig = vcsbackend.create_repo(number_of_commits=5)
211 unrelated = vcsbackend.create_repo(number_of_commits=5)
211 unrelated = vcsbackend.create_repo(number_of_commits=5)
212 assert orig != unrelated
212 assert orig != unrelated
213
213
214 orig.compare(
214 orig.compare(
215 orig[1].raw_id, unrelated[3].raw_id, unrelated, merge=merge)
215 orig[1].raw_id, unrelated[3].raw_id, unrelated, merge=merge)
216
216
217
217
218 class TestRepositoryGetCommonAncestor:
218 class TestRepositoryGetCommonAncestor:
219
219
220 def test_get_common_ancestor_from_same_repo_existing(self, vcsbackend):
220 def test_get_common_ancestor_from_same_repo_existing(self, vcsbackend):
221 target_repo = vcsbackend.create_repo(number_of_commits=5)
221 target_repo = vcsbackend.create_repo(number_of_commits=5)
222
222
223 expected_ancestor = target_repo[2].raw_id
223 expected_ancestor = target_repo[2].raw_id
224
224
225 assert target_repo.get_common_ancestor(
225 assert target_repo.get_common_ancestor(
226 commit_id1=target_repo[2].raw_id,
226 commit_id1=target_repo[2].raw_id,
227 commit_id2=target_repo[4].raw_id,
227 commit_id2=target_repo[4].raw_id,
228 repo2=target_repo
228 repo2=target_repo
229 ) == expected_ancestor
229 ) == expected_ancestor
230
230
231 assert target_repo.get_common_ancestor(
231 assert target_repo.get_common_ancestor(
232 commit_id1=target_repo[4].raw_id,
232 commit_id1=target_repo[4].raw_id,
233 commit_id2=target_repo[2].raw_id,
233 commit_id2=target_repo[2].raw_id,
234 repo2=target_repo
234 repo2=target_repo
235 ) == expected_ancestor
235 ) == expected_ancestor
236
236
237 @pytest.mark.xfail_backends("svn")
237 @pytest.mark.xfail_backends("svn")
238 def test_get_common_ancestor_from_cloned_repo_existing(self, vcsbackend):
238 def test_get_common_ancestor_from_cloned_repo_existing(self, vcsbackend):
239 target_repo = vcsbackend.create_repo(number_of_commits=5)
239 target_repo = vcsbackend.create_repo(number_of_commits=5)
240 source_repo = vcsbackend.clone_repo(target_repo)
240 source_repo = vcsbackend.clone_repo(target_repo)
241 assert target_repo != source_repo
241 assert target_repo != source_repo
242
242
243 vcsbackend.add_file(source_repo, b'newfile', b'somecontent')
243 vcsbackend.add_file(source_repo, b'newfile', b'somecontent')
244 source_commit = source_repo.get_commit()
244 source_commit = source_repo.get_commit()
245
245
246 expected_ancestor = target_repo[4].raw_id
246 expected_ancestor = target_repo[4].raw_id
247
247
248 assert target_repo.get_common_ancestor(
248 assert target_repo.get_common_ancestor(
249 commit_id1=target_repo[4].raw_id,
249 commit_id1=target_repo[4].raw_id,
250 commit_id2=source_commit.raw_id,
250 commit_id2=source_commit.raw_id,
251 repo2=source_repo
251 repo2=source_repo
252 ) == expected_ancestor
252 ) == expected_ancestor
253
253
254 assert target_repo.get_common_ancestor(
254 assert target_repo.get_common_ancestor(
255 commit_id1=source_commit.raw_id,
255 commit_id1=source_commit.raw_id,
256 commit_id2=target_repo[4].raw_id,
256 commit_id2=target_repo[4].raw_id,
257 repo2=target_repo
257 repo2=target_repo
258 ) == expected_ancestor
258 ) == expected_ancestor
259
259
260 @pytest.mark.xfail_backends("svn")
260 @pytest.mark.xfail_backends("svn")
261 def test_get_common_ancestor_from_unrelated_repo_missing(self, vcsbackend):
261 def test_get_common_ancestor_from_unrelated_repo_missing(self, vcsbackend):
262 original = vcsbackend.create_repo(number_of_commits=5)
262 original = vcsbackend.create_repo(number_of_commits=5)
263 unrelated = vcsbackend.create_repo(number_of_commits=5)
263 unrelated = vcsbackend.create_repo(number_of_commits=5)
264 assert original != unrelated
264 assert original != unrelated
265
265
266 assert original.get_common_ancestor(
266 assert original.get_common_ancestor(
267 commit_id1=original[0].raw_id,
267 commit_id1=original[0].raw_id,
268 commit_id2=unrelated[0].raw_id,
268 commit_id2=unrelated[0].raw_id,
269 repo2=unrelated
269 repo2=unrelated
270 ) is None
270 ) is None
271
271
272 assert original.get_common_ancestor(
272 assert original.get_common_ancestor(
273 commit_id1=original[-1].raw_id,
273 commit_id1=original[-1].raw_id,
274 commit_id2=unrelated[-1].raw_id,
274 commit_id2=unrelated[-1].raw_id,
275 repo2=unrelated
275 repo2=unrelated
276 ) is None
276 ) is None
277
277
278
278
279 @pytest.mark.backends("git", "hg")
279 @pytest.mark.backends("git", "hg")
280 class TestRepositoryMerge(object):
280 class TestRepositoryMerge(object):
281 def prepare_for_success(self, vcsbackend):
281 def prepare_for_success(self, vcsbackend):
282 self.target_repo = vcsbackend.create_repo(number_of_commits=1)
282 self.target_repo = vcsbackend.create_repo(number_of_commits=1)
283 self.source_repo = vcsbackend.clone_repo(self.target_repo)
283 self.source_repo = vcsbackend.clone_repo(self.target_repo)
284 vcsbackend.add_file(self.target_repo, b'README_MERGE1', b'Version 1')
284 vcsbackend.add_file(self.target_repo, b'README_MERGE1', b'Version 1')
285 vcsbackend.add_file(self.source_repo, b'README_MERGE2', b'Version 2')
285 vcsbackend.add_file(self.source_repo, b'README_MERGE2', b'Version 2')
286 imc = self.source_repo.in_memory_commit
286 imc = self.source_repo.in_memory_commit
287 imc.add(FileNode(b'file_x', content=self.source_repo.name))
287 imc.add(FileNode(b'file_x', content=self.source_repo.name))
288 imc.commit(
288 imc.commit(
289 message=u'Automatic commit from repo merge test',
289 message=u'Automatic commit from repo merge test',
290 author=u'Automatic <automatic@rhodecode.com>')
290 author=u'Automatic <automatic@rhodecode.com>')
291 self.target_commit = self.target_repo.get_commit()
291 self.target_commit = self.target_repo.get_commit()
292 self.source_commit = self.source_repo.get_commit()
292 self.source_commit = self.source_repo.get_commit()
293 # This only works for Git and Mercurial
293 # This only works for Git and Mercurial
294 default_branch = self.target_repo.DEFAULT_BRANCH_NAME
294 default_branch = self.target_repo.DEFAULT_BRANCH_NAME
295 self.target_ref = Reference('branch', default_branch, self.target_commit.raw_id)
295 self.target_ref = Reference('branch', default_branch, self.target_commit.raw_id)
296 self.source_ref = Reference('branch', default_branch, self.source_commit.raw_id)
296 self.source_ref = Reference('branch', default_branch, self.source_commit.raw_id)
297 self.workspace_id = 'test-merge-{}'.format(vcsbackend.alias)
297 self.workspace_id = 'test-merge-{}'.format(vcsbackend.alias)
298 self.repo_id = repo_id_generator(self.target_repo.path)
298 self.repo_id = repo_id_generator(self.target_repo.path)
299
299
300 def prepare_for_conflict(self, vcsbackend):
300 def prepare_for_conflict(self, vcsbackend):
301 self.target_repo = vcsbackend.create_repo(number_of_commits=1)
301 self.target_repo = vcsbackend.create_repo(number_of_commits=1)
302 self.source_repo = vcsbackend.clone_repo(self.target_repo)
302 self.source_repo = vcsbackend.clone_repo(self.target_repo)
303 vcsbackend.add_file(self.target_repo, b'README_MERGE', b'Version 1')
303 vcsbackend.add_file(self.target_repo, b'README_MERGE', b'Version 1')
304 vcsbackend.add_file(self.source_repo, b'README_MERGE', b'Version 2')
304 vcsbackend.add_file(self.source_repo, b'README_MERGE', b'Version 2')
305 self.target_commit = self.target_repo.get_commit()
305 self.target_commit = self.target_repo.get_commit()
306 self.source_commit = self.source_repo.get_commit()
306 self.source_commit = self.source_repo.get_commit()
307 # This only works for Git and Mercurial
307 # This only works for Git and Mercurial
308 default_branch = self.target_repo.DEFAULT_BRANCH_NAME
308 default_branch = self.target_repo.DEFAULT_BRANCH_NAME
309 self.target_ref = Reference('branch', default_branch, self.target_commit.raw_id)
309 self.target_ref = Reference('branch', default_branch, self.target_commit.raw_id)
310 self.source_ref = Reference('branch', default_branch, self.source_commit.raw_id)
310 self.source_ref = Reference('branch', default_branch, self.source_commit.raw_id)
311 self.workspace_id = 'test-merge-{}'.format(vcsbackend.alias)
311 self.workspace_id = 'test-merge-{}'.format(vcsbackend.alias)
312 self.repo_id = repo_id_generator(self.target_repo.path)
312 self.repo_id = repo_id_generator(self.target_repo.path)
313
313
314 def test_merge_success(self, vcsbackend):
314 def test_merge_success(self, vcsbackend):
315 self.prepare_for_success(vcsbackend)
315 self.prepare_for_success(vcsbackend)
316
316
317 merge_response = self.target_repo.merge(
317 merge_response = self.target_repo.merge(
318 self.repo_id, self.workspace_id, self.target_ref, self.source_repo,
318 self.repo_id, self.workspace_id, self.target_ref, self.source_repo,
319 self.source_ref,
319 self.source_ref,
320 'test user', 'test@rhodecode.com', 'merge message 1',
320 'test user', 'test@rhodecode.com', 'merge message 1',
321 dry_run=False)
321 dry_run=False)
322 expected_merge_response = MergeResponse(
322 expected_merge_response = MergeResponse(
323 True, True, merge_response.merge_ref,
323 True, True, merge_response.merge_ref,
324 MergeFailureReason.NONE)
324 MergeFailureReason.NONE)
325 assert merge_response == expected_merge_response
325 assert merge_response == expected_merge_response
326
326
327 target_repo = backends.get_backend(vcsbackend.alias)(
327 target_repo = backends.get_backend(vcsbackend.alias)(
328 self.target_repo.path)
328 self.target_repo.path)
329 target_commits = list(target_repo.get_commits())
329 target_commits = list(target_repo.get_commits())
330 commit_ids = [c.raw_id for c in target_commits[:-1]]
330 commit_ids = [c.raw_id for c in target_commits[:-1]]
331 assert self.source_ref.commit_id in commit_ids
331 assert self.source_ref.commit_id in commit_ids
332 assert self.target_ref.commit_id in commit_ids
332 assert self.target_ref.commit_id in commit_ids
333
333
334 merge_commit = target_commits[-1]
334 merge_commit = target_commits[-1]
335 assert merge_commit.raw_id == merge_response.merge_ref.commit_id
335 assert merge_commit.raw_id == merge_response.merge_ref.commit_id
336 assert merge_commit.message.strip() == 'merge message 1'
336 assert merge_commit.message.strip() == 'merge message 1'
337 assert merge_commit.author == 'test user <test@rhodecode.com>'
337 assert merge_commit.author == 'test user <test@rhodecode.com>'
338
338
339 # We call it twice so to make sure we can handle updates
339 # We call it twice so to make sure we can handle updates
340 target_ref = Reference(
340 target_ref = Reference(
341 self.target_ref.type, self.target_ref.name,
341 self.target_ref.type, self.target_ref.name,
342 merge_response.merge_ref.commit_id)
342 merge_response.merge_ref.commit_id)
343
343
344 merge_response = target_repo.merge(
344 merge_response = target_repo.merge(
345 self.repo_id, self.workspace_id, target_ref, self.source_repo, self.source_ref,
345 self.repo_id, self.workspace_id, target_ref, self.source_repo, self.source_ref,
346 'test user', 'test@rhodecode.com', 'merge message 2',
346 'test user', 'test@rhodecode.com', 'merge message 2',
347 dry_run=False)
347 dry_run=False)
348 expected_merge_response = MergeResponse(
348 expected_merge_response = MergeResponse(
349 True, True, merge_response.merge_ref,
349 True, True, merge_response.merge_ref,
350 MergeFailureReason.NONE)
350 MergeFailureReason.NONE)
351 assert merge_response == expected_merge_response
351 assert merge_response == expected_merge_response
352
352
353 target_repo = backends.get_backend(
353 target_repo = backends.get_backend(
354 vcsbackend.alias)(self.target_repo.path)
354 vcsbackend.alias)(self.target_repo.path)
355 merge_commit = target_repo.get_commit(
355 merge_commit = target_repo.get_commit(
356 merge_response.merge_ref.commit_id)
356 merge_response.merge_ref.commit_id)
357 assert merge_commit.message.strip() == 'merge message 1'
357 assert merge_commit.message.strip() == 'merge message 1'
358 assert merge_commit.author == 'test user <test@rhodecode.com>'
358 assert merge_commit.author == 'test user <test@rhodecode.com>'
359
359
360 def test_merge_success_dry_run(self, vcsbackend):
360 def test_merge_success_dry_run(self, vcsbackend):
361 self.prepare_for_success(vcsbackend)
361 self.prepare_for_success(vcsbackend)
362
362
363 merge_response = self.target_repo.merge(
363 merge_response = self.target_repo.merge(
364 self.repo_id, self.workspace_id, self.target_ref, self.source_repo,
364 self.repo_id, self.workspace_id, self.target_ref, self.source_repo,
365 self.source_ref, dry_run=True)
365 self.source_ref, dry_run=True)
366
366
367 # We call it twice so to make sure we can handle updates
367 # We call it twice so to make sure we can handle updates
368 merge_response_update = self.target_repo.merge(
368 merge_response_update = self.target_repo.merge(
369 self.repo_id, self.workspace_id, self.target_ref, self.source_repo,
369 self.repo_id, self.workspace_id, self.target_ref, self.source_repo,
370 self.source_ref, dry_run=True)
370 self.source_ref, dry_run=True)
371
371
372 # Multiple merges may differ in their commit id. Therefore we set the
372 # Multiple merges may differ in their commit id. Therefore, we set the
373 # commit id to `None` before comparing the merge responses.
373 # commit id to `None` before comparing the merge responses.
374 new_merge_ref = merge_response.merge_ref.commit_id = None
374 new_merge_ref = merge_response.merge_ref.commit_id = None
375 merge_response.merge_ref = new_merge_ref
375 merge_response.merge_ref = new_merge_ref
376
376
377 new_update_merge_ref = merge_response_update.merge_ref.commit_id = None
377 new_update_merge_ref = merge_response_update.merge_ref.commit_id = None
378 merge_response_update.merge_ref = new_update_merge_ref
378 merge_response_update.merge_ref = new_update_merge_ref
379
379
380 assert merge_response == merge_response_update
380 assert merge_response == merge_response_update
381 assert merge_response.possible is True
381 assert merge_response.possible is True
382 assert merge_response.executed is False
382 assert merge_response.executed is False
383 assert merge_response.merge_ref
383 assert merge_response.merge_ref
384 assert merge_response.failure_reason is MergeFailureReason.NONE
384 assert merge_response.failure_reason is MergeFailureReason.NONE
385
385
386 @pytest.mark.parametrize('dry_run', [True, False])
386 @pytest.mark.parametrize('dry_run', [True, False])
387 def test_merge_conflict(self, vcsbackend, dry_run):
387 def test_merge_conflict(self, vcsbackend, dry_run):
388 self.prepare_for_conflict(vcsbackend)
388 self.prepare_for_conflict(vcsbackend)
389
389
390 expected_merge_response = MergeResponse(
390 expected_merge_response = MergeResponse(
391 False, False, None, MergeFailureReason.MERGE_FAILED)
391 False, False, None, MergeFailureReason.MERGE_FAILED)
392
392
393 merge_response = self.target_repo.merge(
393 merge_response = self.target_repo.merge(
394 self.repo_id, self.workspace_id, self.target_ref,
394 self.repo_id, self.workspace_id, self.target_ref,
395 self.source_repo, self.source_ref,
395 self.source_repo, self.source_ref,
396 'test_user', 'test@rhodecode.com', 'test message', dry_run=dry_run)
396 'test_user', 'test@rhodecode.com', 'test message', dry_run=dry_run)
397 assert merge_response == expected_merge_response
397 assert merge_response == expected_merge_response
398
398
399 # We call it twice so to make sure we can handle updates
399 # We call it twice so to make sure we can handle updates
400 merge_response = self.target_repo.merge(
400 merge_response = self.target_repo.merge(
401 self.repo_id, self.workspace_id, self.target_ref, self.source_repo,
401 self.repo_id, self.workspace_id, self.target_ref, self.source_repo,
402 self.source_ref,
402 self.source_ref,
403 'test_user', 'test@rhodecode.com', 'test message', dry_run=dry_run)
403 'test_user', 'test@rhodecode.com', 'test message', dry_run=dry_run)
404 assert merge_response == expected_merge_response
404 assert merge_response == expected_merge_response
405
405
406 def test_merge_target_is_not_head(self, vcsbackend):
406 def test_merge_target_is_not_head(self, vcsbackend):
407 self.prepare_for_success(vcsbackend)
407 self.prepare_for_success(vcsbackend)
408 target_ref = Reference(
408 target_ref = Reference(
409 self.target_ref.type, self.target_ref.name, '0' * 40)
409 self.target_ref.type, self.target_ref.name, '0' * 40)
410 expected_merge_response = MergeResponse(
410 expected_merge_response = MergeResponse(
411 False, False, None, MergeFailureReason.TARGET_IS_NOT_HEAD,
411 False, False, None, MergeFailureReason.TARGET_IS_NOT_HEAD,
412 metadata={'target_ref': target_ref})
412 metadata={'target_ref': target_ref})
413 merge_response = self.target_repo.merge(
413 merge_response = self.target_repo.merge(
414 self.repo_id, self.workspace_id, target_ref, self.source_repo,
414 self.repo_id, self.workspace_id, target_ref, self.source_repo,
415 self.source_ref, dry_run=True)
415 self.source_ref, dry_run=True)
416
416
417 assert merge_response == expected_merge_response
417 assert merge_response == expected_merge_response
418
418
419 def test_merge_missing_source_reference(self, vcsbackend):
419 def test_merge_missing_source_reference(self, vcsbackend):
420 self.prepare_for_success(vcsbackend)
420 self.prepare_for_success(vcsbackend)
421
421
422 source_ref = Reference(
422 source_ref = Reference(
423 self.source_ref.type, 'not_existing', self.source_ref.commit_id)
423 self.source_ref.type, 'not_existing', self.source_ref.commit_id)
424 expected_merge_response = MergeResponse(
424 expected_merge_response = MergeResponse(
425 False, False, None, MergeFailureReason.MISSING_SOURCE_REF,
425 False, False, None, MergeFailureReason.MISSING_SOURCE_REF,
426 metadata={'source_ref': source_ref})
426 metadata={'source_ref': source_ref})
427
427
428 merge_response = self.target_repo.merge(
428 merge_response = self.target_repo.merge(
429 self.repo_id, self.workspace_id, self.target_ref,
429 self.repo_id, self.workspace_id, self.target_ref,
430 self.source_repo, source_ref,
430 self.source_repo, source_ref,
431 dry_run=True)
431 dry_run=True)
432
432
433 assert merge_response == expected_merge_response
433 assert merge_response == expected_merge_response
434
434
435 def test_merge_raises_exception(self, vcsbackend):
435 def test_merge_raises_exception(self, vcsbackend):
436 self.prepare_for_success(vcsbackend)
436 self.prepare_for_success(vcsbackend)
437 expected_merge_response = MergeResponse(
437 expected_merge_response = MergeResponse(
438 False, False, None, MergeFailureReason.UNKNOWN,
438 False, False, None, MergeFailureReason.UNKNOWN,
439 metadata={'exception': 'ErrorForTest'})
439 metadata={'exception': 'ErrorForTest'})
440
440
441 with mock.patch.object(self.target_repo, '_merge_repo',
441 with mock.patch.object(self.target_repo, '_merge_repo',
442 side_effect=RepositoryError()):
442 side_effect=RepositoryError()):
443 merge_response = self.target_repo.merge(
443 merge_response = self.target_repo.merge(
444 self.repo_id, self.workspace_id, self.target_ref,
444 self.repo_id, self.workspace_id, self.target_ref,
445 self.source_repo, self.source_ref,
445 self.source_repo, self.source_ref,
446 dry_run=True)
446 dry_run=True)
447
447
448 assert merge_response == expected_merge_response
448 assert merge_response == expected_merge_response
449
449
450 def test_merge_invalid_user_name(self, vcsbackend):
450 def test_merge_invalid_user_name(self, vcsbackend):
451 repo = vcsbackend.create_repo(number_of_commits=1)
451 repo = vcsbackend.create_repo(number_of_commits=1)
452 ref = Reference('branch', 'master', 'not_used')
452 ref = Reference('branch', 'master', 'not_used')
453 workspace_id = 'test-errors-in-merge'
453 workspace_id = 'test-errors-in-merge'
454 repo_id = repo_id_generator(workspace_id)
454 repo_id = repo_id_generator(workspace_id)
455 with pytest.raises(ValueError):
455 with pytest.raises(ValueError):
456 repo.merge(repo_id, workspace_id, ref, self, ref)
456 repo.merge(repo_id, workspace_id, ref, self, ref)
457
457
458 def test_merge_invalid_user_email(self, vcsbackend):
458 def test_merge_invalid_user_email(self, vcsbackend):
459 repo = vcsbackend.create_repo(number_of_commits=1)
459 repo = vcsbackend.create_repo(number_of_commits=1)
460 ref = Reference('branch', 'master', 'not_used')
460 ref = Reference('branch', 'master', 'not_used')
461 workspace_id = 'test-errors-in-merge'
461 workspace_id = 'test-errors-in-merge'
462 repo_id = repo_id_generator(workspace_id)
462 repo_id = repo_id_generator(workspace_id)
463 with pytest.raises(ValueError):
463 with pytest.raises(ValueError):
464 repo.merge(
464 repo.merge(
465 repo_id, workspace_id, ref, self, ref, 'user name')
465 repo_id, workspace_id, ref, self, ref, 'user name')
466
466
467 def test_merge_invalid_message(self, vcsbackend):
467 def test_merge_invalid_message(self, vcsbackend):
468 repo = vcsbackend.create_repo(number_of_commits=1)
468 repo = vcsbackend.create_repo(number_of_commits=1)
469 ref = Reference('branch', 'master', 'not_used')
469 ref = Reference('branch', 'master', 'not_used')
470 workspace_id = 'test-errors-in-merge'
470 workspace_id = 'test-errors-in-merge'
471 repo_id = repo_id_generator(workspace_id)
471 repo_id = repo_id_generator(workspace_id)
472 with pytest.raises(ValueError):
472 with pytest.raises(ValueError):
473 repo.merge(
473 repo.merge(
474 repo_id, workspace_id, ref, self, ref,
474 repo_id, workspace_id, ref, self, ref,
475 'user name', 'user@email.com')
475 'user name', 'user@email.com')
476
476
477
477
478 @pytest.mark.usefixtures("vcs_repository_support")
478 @pytest.mark.usefixtures("vcs_repository_support")
479 class TestRepositoryStrip(BackendTestMixin):
479 class TestRepositoryStrip(BackendTestMixin):
480 recreate_repo_per_test = True
480 recreate_repo_per_test = True
481
481
482 @classmethod
482 @classmethod
483 def _get_commits(cls):
483 def _get_commits(cls):
484 commits = [
484 commits = [
485 {
485 {
486 'message': 'Initial commit',
486 'message': 'Initial commit',
487 'author': 'Joe Doe <joe.doe@example.com>',
487 'author': 'Joe Doe <joe.doe@example.com>',
488 'date': datetime.datetime(2010, 1, 1, 20),
488 'date': datetime.datetime(2010, 1, 1, 20),
489 'branch': 'master',
489 'branch': 'master',
490 'added': [
490 'added': [
491 FileNode(b'foobar', content='foobar'),
491 FileNode(b'foobar', content='foobar'),
492 FileNode(b'foobar2', content='foobar2'),
492 FileNode(b'foobar2', content='foobar2'),
493 ],
493 ],
494 },
494 },
495 ]
495 ]
496 for x in range(10):
496 for x in range(10):
497 commit_data = {
497 commit_data = {
498 'message': 'Changed foobar - commit%s' % x,
498 'message': 'Changed foobar - commit%s' % x,
499 'author': 'Jane Doe <jane.doe@example.com>',
499 'author': 'Jane Doe <jane.doe@example.com>',
500 'date': datetime.datetime(2010, 1, 1, 21, x),
500 'date': datetime.datetime(2010, 1, 1, 21, x),
501 'branch': 'master',
501 'branch': 'master',
502 'changed': [
502 'changed': [
503 FileNode(b'foobar', 'FOOBAR - %s' % x),
503 FileNode(b'foobar', 'FOOBAR - %s' % x),
504 ],
504 ],
505 }
505 }
506 commits.append(commit_data)
506 commits.append(commit_data)
507 return commits
507 return commits
508
508
509 @pytest.mark.backends("git", "hg")
509 @pytest.mark.backends("git", "hg")
510 def test_strip_commit(self):
510 def test_strip_commit(self):
511 tip = self.repo.get_commit()
511 tip = self.repo.get_commit()
512 assert tip.idx == 10
512 assert tip.idx == 10
513 self.repo.strip(tip.raw_id, self.repo.DEFAULT_BRANCH_NAME)
513 self.repo.strip(tip.raw_id, self.repo.DEFAULT_BRANCH_NAME)
514
514
515 tip = self.repo.get_commit()
515 tip = self.repo.get_commit()
516 assert tip.idx == 9
516 assert tip.idx == 9
517
517
518 @pytest.mark.backends("git", "hg")
518 @pytest.mark.backends("git", "hg")
519 def test_strip_multiple_commits(self):
519 def test_strip_multiple_commits(self):
520 tip = self.repo.get_commit()
520 tip = self.repo.get_commit()
521 assert tip.idx == 10
521 assert tip.idx == 10
522
522
523 old = self.repo.get_commit(commit_idx=5)
523 old = self.repo.get_commit(commit_idx=5)
524 self.repo.strip(old.raw_id, self.repo.DEFAULT_BRANCH_NAME)
524 self.repo.strip(old.raw_id, self.repo.DEFAULT_BRANCH_NAME)
525
525
526 tip = self.repo.get_commit()
526 tip = self.repo.get_commit()
527 assert tip.idx == 4
527 assert tip.idx == 4
528
528
529
529
530 @pytest.mark.backends('hg', 'git')
530 @pytest.mark.backends('hg', 'git')
531 class TestRepositoryPull(object):
531 class TestRepositoryPull(object):
532
532
533 def test_pull(self, vcsbackend):
533 def test_pull(self, vcsbackend):
534 source_repo = vcsbackend.repo
534 source_repo = vcsbackend.repo
535 target_repo = vcsbackend.create_repo()
535 target_repo = vcsbackend.create_repo()
536 assert len(source_repo.commit_ids) > len(target_repo.commit_ids)
536 assert len(source_repo.commit_ids) > len(target_repo.commit_ids)
537
537
538 target_repo.pull(source_repo.path)
538 target_repo.pull(source_repo.path)
539 # Note: Get a fresh instance, avoids caching trouble
539 # Note: Get a fresh instance, avoids caching trouble
540 target_repo = vcsbackend.backend(target_repo.path)
540 target_repo = vcsbackend.backend(target_repo.path)
541 assert len(source_repo.commit_ids) == len(target_repo.commit_ids)
541 assert len(source_repo.commit_ids) == len(target_repo.commit_ids)
542
542
543 def test_pull_wrong_path(self, vcsbackend):
543 def test_pull_wrong_path(self, vcsbackend):
544 target_repo = vcsbackend.create_repo()
544 target_repo = vcsbackend.create_repo()
545 with pytest.raises(RepositoryError):
545 with pytest.raises(RepositoryError):
546 target_repo.pull(target_repo.path + "wrong")
546 target_repo.pull(target_repo.path + "wrong")
547
547
548 def test_pull_specific_commits(self, vcsbackend):
548 def test_pull_specific_commits(self, vcsbackend):
549 source_repo = vcsbackend.repo
549 source_repo = vcsbackend.repo
550 target_repo = vcsbackend.create_repo()
550 target_repo = vcsbackend.create_repo()
551
551
552 second_commit = source_repo[1].raw_id
552 second_commit = source_repo[1].raw_id
553 if vcsbackend.alias == 'git':
553 if vcsbackend.alias == 'git':
554 second_commit_ref = 'refs/test-refs/a'
554 second_commit_ref = 'refs/test-refs/a'
555 source_repo.set_refs(second_commit_ref, second_commit)
555 source_repo.set_refs(second_commit_ref, second_commit)
556
556
557 target_repo.pull(source_repo.path, commit_ids=[second_commit])
557 target_repo.pull(source_repo.path, commit_ids=[second_commit])
558 target_repo = vcsbackend.backend(target_repo.path)
558 target_repo = vcsbackend.backend(target_repo.path)
559 assert 2 == len(target_repo.commit_ids)
559 assert 2 == len(target_repo.commit_ids)
560 assert second_commit == target_repo.get_commit().raw_id
560 assert second_commit == target_repo.get_commit().raw_id
General Comments 0
You need to be logged in to leave comments. Login now