3030 NotableDomain ,
3131 PreprintContributor ,
3232 DraftRegistrationContributor ,
33- DraftRegistration ,
34- DraftNode ,
3533 UserSessionMap ,
3634)
3735from osf .models .institution_affiliation import get_user_by_institution_identity
@@ -2116,26 +2114,6 @@ def test_can_gdpr_delete_personal_nodes(self, user):
21162114 user .gdpr_delete ()
21172115 assert user .nodes .exclude (is_deleted = True ).count () == 0
21182116
2119- def test_can_gdpr_delete_personal_registrations (self , user , registration_with_draft_node ):
2120- assert DraftRegistration .objects .all ().count () == 1
2121- assert DraftNode .objects .all ().count () == 1
2122-
2123- with pytest .raises (UserStateError ) as exc_info :
2124- user .gdpr_delete ()
2125-
2126- assert exc_info .value .args [0 ] == 'You cannot delete this user because they have one or more registrations.'
2127- assert DraftRegistration .objects .all ().count () == 1
2128- assert DraftNode .objects .all ().count () == 1
2129-
2130- registration_with_draft_node .remove_node (Auth (user ))
2131- assert DraftRegistration .objects .all ().count () == 1
2132- assert DraftNode .objects .all ().count () == 1
2133- user .gdpr_delete ()
2134-
2135- # DraftNodes soft-deleted, DraftRegistions hard-deleted
2136- assert user .nodes .exclude (is_deleted = True ).count () == 0
2137- assert DraftRegistration .objects .all ().count () == 0
2138-
21392117 def test_can_gdpr_delete_shared_nodes_with_multiple_admins (self , user , project_with_two_admins ):
21402118
21412119 user .gdpr_delete ()
@@ -2144,28 +2122,61 @@ def test_can_gdpr_delete_shared_nodes_with_multiple_admins(self, user, project_w
21442122 def test_can_gdpr_delete_shared_draft_registration_with_multiple_admins (self , user , registration ):
21452123 other_admin = AuthUserFactory ()
21462124 draft_registrations = user .draft_registrations .get ()
2147- draft_registrations .add_contributor (other_admin , permissions = 'admin' )
2125+ draft_registrations .add_contributor (other_admin , auth = Auth ( user ), permissions = 'admin' )
21482126 assert draft_registrations .contributors .all ().count () == 2
21492127 registration .delete_registration_tree (save = True )
21502128
21512129 user .gdpr_delete ()
21522130 assert draft_registrations .contributors .get () == other_admin
21532131 assert user .nodes .filter (deleted__isnull = True ).count () == 0
21542132
2155- def test_cant_gdpr_delete_registrations (self , user , registration ):
2133+ def test_cant_gdpr_delete_multiple_contributors_registrations (self , user , registration ):
2134+ registration .is_public = True
2135+ other_user = AuthUserFactory ()
2136+ registration .add_contributor (other_user , auth = Auth (user ), permissions = 'admin' )
2137+ registration .save ()
2138+
2139+ assert registration .contributors .count () == 2
21562140
21572141 with pytest .raises (UserStateError ) as exc_info :
21582142 user .gdpr_delete ()
21592143
21602144 assert exc_info .value .args [0 ] == 'You cannot delete this user because they have one or more registrations.'
21612145
2162- def test_cant_gdpr_delete_preprints (self , user , preprint ):
2146+ def test_cant_gdpr_delete_multiple_contributors_preprints (self , user , preprint ):
2147+ other_user = AuthUserFactory ()
2148+ preprint .add_contributor (other_user , auth = Auth (user ), permissions = 'admin' )
2149+ preprint .save ()
21632150
21642151 with pytest .raises (UserStateError ) as exc_info :
21652152 user .gdpr_delete ()
21662153
21672154 assert exc_info .value .args [0 ] == 'You cannot delete this user because they have one or more preprints.'
21682155
2156+ def test_can_gdpr_delete_sole_contributor_registration (self , user ):
2157+ registration = RegistrationFactory (creator = user )
2158+ registration .save ()
2159+
2160+ assert registration .contributors .count () == 1
2161+ assert registration .contributors .first () == user
2162+
2163+ user .gdpr_delete ()
2164+
2165+ assert user .fullname == 'Deleted user'
2166+ assert user .deleted is not None
2167+
2168+ def test_can_gdpr_delete_sole_contributor_preprint (self , user ):
2169+ preprint = PreprintFactory (creator = user )
2170+ preprint .save ()
2171+
2172+ assert preprint .contributors .count () == 1
2173+ assert preprint .contributors .first () == user
2174+
2175+ user .gdpr_delete ()
2176+
2177+ assert user .fullname == 'Deleted user'
2178+ assert user .deleted is not None
2179+
21692180 def test_cant_gdpr_delete_shared_node_if_only_admin (self , user , project_user_is_only_admin ):
21702181
21712182 with pytest .raises (UserStateError ) as exc_info :
0 commit comments