|
8 | 8 | ) |
9 | 9 | from api_tests.nodes.views.test_node_contributors_detail_ordering import TestNodeContributorOrdering |
10 | 10 | from api_tests.nodes.views.test_node_contributors_detail_update import TestNodeContributorUpdate |
| 11 | +from api_tests.utils import disconnected_from_listeners |
11 | 12 | from osf_tests.factories import ( |
12 | 13 | DraftRegistrationFactory, |
13 | 14 | ProjectFactory, |
14 | 15 | AuthUserFactory |
15 | 16 | ) |
16 | 17 | from osf.utils import permissions |
| 18 | +from website.project.signals import contributor_removed |
17 | 19 |
|
18 | 20 |
|
19 | 21 | @pytest.fixture() |
@@ -251,6 +253,30 @@ def url_user_non_contrib(self, project, user_non_contrib): |
251 | 253 | return '/{}draft_registrations/{}/contributors/{}/'.format( |
252 | 254 | API_BASE, project._id, user_non_contrib._id) |
253 | 255 |
|
| 256 | + def test_remove_contributor_include_children_removes_descendants(self, app, user, user_write_contrib, project): |
| 257 | + assert user_write_contrib in project.contributors |
| 258 | + |
| 259 | + url = f'/{API_BASE}draft_registrations/{project._id}/contributors/{user_write_contrib._id}/?include_children=true' |
| 260 | + with disconnected_from_listeners(contributor_removed): |
| 261 | + res = app.delete(url, auth=user.auth) |
| 262 | + assert res.status_code == 204 |
| 263 | + |
| 264 | + project.reload() |
| 265 | + assert user_write_contrib not in project.contributors |
| 266 | + |
| 267 | + def test_remove_contributor_include_children_is_atomic_on_violation(self, app, user, user_write_contrib, project): |
| 268 | + assert user_write_contrib in project.contributors |
| 269 | + |
| 270 | + # Draft registrations don't have children, so include_children parameter is ignored |
| 271 | + # The contributor should be removed successfully since there are no children to cause violations |
| 272 | + url = f'/{API_BASE}draft_registrations/{project._id}/contributors/{user_write_contrib._id}/?include_children=true' |
| 273 | + with disconnected_from_listeners(contributor_removed): |
| 274 | + res = app.delete(url, auth=user.auth) |
| 275 | + assert res.status_code == 204 |
| 276 | + |
| 277 | + project.reload() |
| 278 | + assert user_write_contrib not in project.contributors |
| 279 | + |
254 | 280 |
|
255 | 281 | @pytest.mark.django_db |
256 | 282 | class TestDraftBibliographicContributorDetail(): |
|
0 commit comments