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