@@ -119,7 +119,9 @@ def test_collection_lifecycle(database, fastapi, caplog, who):
119119 ] = """
120120 A bit less abstract...
121121 """
122- the_coll ["short_title" ] = "my-tiny-title"
122+ # short_title only on second round
123+ if who == CREATOR_AUTH :
124+ the_coll ["short_title" ] = "my-tiny-title"
123125 the_coll ["associate_organisations" ] = ["An org" ]
124126 the_coll ["creator_organisations" ] = ["At least one (ONE)" ]
125127 rsp = fastapi .put (url , headers = who , json = the_coll )
@@ -136,6 +138,11 @@ def test_collection_lifecycle(database, fastapi, caplog, who):
136138 url = COLLECTION_SEARCH_URL .format (title = "%coll%" )
137139 rsp = fastapi .get (url , headers = who )
138140 assert rsp .status_code == status .HTTP_200_OK
141+ if who == CREATOR_AUTH :
142+ short_title = "my-tiny-title"
143+ else :
144+ short_title = None
145+
139146 assert rsp .json () == [
140147 {
141148 "abstract" : """
@@ -155,7 +162,7 @@ def test_collection_lifecycle(database, fastapi, caplog, who):
155162 "project_ids" : [prj_id ],
156163 "provider_user" : None ,
157164 "title" : "Test collection" ,
158- "short_title" : "my-tiny-title" ,
165+ "short_title" : short_title ,
159166 }
160167 ]
161168
@@ -169,10 +176,11 @@ def test_collection_lifecycle(database, fastapi, caplog, who):
169176 the_coll = {"project_ids" : [prj_id ]}
170177 rsp = fastapi .patch (url , headers = who , json = the_coll )
171178 assert rsp .status_code == status .HTTP_200_OK
172- # Search by short title
173- url = COLLECTION_EXACT_QUERY_URL .format (short_title = "my-tiny-title" )
174- rsp = fastapi .get (url , headers = who )
175- assert rsp .status_code == status .HTTP_200_OK
179+ if who == CREATOR_AUTH :
180+ # Search by short title
181+ url = COLLECTION_EXACT_QUERY_URL .format (short_title = "my-tiny-title" )
182+ rsp = fastapi .get (url , headers = who )
183+ assert rsp .status_code == status .HTTP_200_OK
176184
177185 # Wrong search by short title
178186 url = COLLECTION_EXACT_QUERY_URL .format (short_title = "my-absent-title" )
@@ -188,12 +196,15 @@ def test_collection_lifecycle(database, fastapi, caplog, who):
188196 # Delete the collection
189197 url = COLLECTION_DELETE_URL .format (collection_id = coll_id )
190198 rsp = fastapi .delete (url , headers = who )
191- assert rsp .status_code == status .HTTP_200_OK
192-
193- # Ensure it's gone
194- url = COLLECTION_QUERY_URL .format (collection_id = coll_id )
195- rsp = fastapi .get (url , headers = who )
196- assert rsp .status_code == status .HTTP_404_NOT_FOUND
199+ if who == CREATOR_AUTH :
200+ # collection is published cannot delete
201+ assert rsp .status_code == 409
202+ else :
203+ assert rsp .status_code == status .HTTP_200_OK
204+ # Ensure it's gone
205+ url = COLLECTION_QUERY_URL .format (collection_id = coll_id )
206+ rsp = fastapi .get (url , headers = who )
207+ assert rsp .status_code == status .HTTP_404_NOT_FOUND
197208
198209
199210def regrant_if_needed (fastapi , prj_id , who ):
0 commit comments