Skip to content

Commit 85d6b32

Browse files
committed
MOD : pull request modifs
1 parent 5303122 commit 85d6b32

File tree

19 files changed

+1153
-440
lines changed

19 files changed

+1153
-440
lines changed

QA/py/pg_files/upgrade_prod.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2925,10 +2925,10 @@ ALTER TABLE projects ADD COLUMN access VARCHAR(1);
29252925
-- PUBLIC ="1" when visible=True and no license
29262926
UPDATE projects SET access='1' WHERE visible=true AND (license='' OR license IS NULL);
29272927
-- OPEN="2" when visible=True and license = CC
2928-
UPDATE projects SET access='2' WHERE visible=true AND license!='' AND LOWER(license) NOT LIKE 'copyright';
2928+
UPDATE projects SET access='2' WHERE visible=true AND license!='' AND LOWER(license)!='copyright';
29292929

29302930
-- private when copyright or visible=False
2931-
UPDATE projects SET access='0' WHERE visible=false OR LOWER(license) LIKE 'copyright';
2931+
UPDATE projects SET access='0' WHERE visible=false OR LOWER(license)='copyright';
29322932
ALTER TABLE projects ALTER COLUMN access SET NOT NULL;
29332933
ALTER TABLE projects ADD COLUMN formulae VARCHAR;
29342934

QA/py/tests/test_collections.py

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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

199210
def regrant_if_needed(fastapi, prj_id, who):

QA/py/tests/test_update_prj.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ def test_update_prj(database, fastapi, caplog):
182182
"title": "Test Project Updates",
183183
"viewers": [],
184184
"visible": True,
185-
"access":AccessLevelEnum.PUBLIC.value,
186-
"formulae":None
185+
"access": AccessLevelEnum.PUBLIC.value,
186+
"formulae": None,
187187
}
188188

189189
read_json = rsp.json()
@@ -208,7 +208,7 @@ def test_update_prj(database, fastapi, caplog):
208208
rsp = fastapi.get(url, headers=ADMIN_AUTH)
209209
assert rsp.json() != ref_json
210210
assert rsp.json()["comments"] == "New comment"
211-
assert rsp.json()["access"]==AccessLevelEnum.PRIVATE.value
211+
assert rsp.json()["access"] == AccessLevelEnum.PRIVATE.value
212212

213213
# For ecotaxa/ecotaxa_dev#602
214214
# Set no contact at all

QA/py/tests/test_v_guest.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,11 @@
33

44
from tests.credentials import ADMIN_AUTH, USER_AUTH, ORDINARY_GUEST_GUEST_ID
55

6-
7-
# noinspection PyPackageRequirements
8-
9-
106
GUEST_UPDATE_URL = "/guests/{guest_id}"
11-
127
GUEST_CREATE_URL = "/guests/create"
13-
148
GUEST_GET_URL = "/guests"
159

16-
#WARNING must run after all test_user
10+
#WARNING must run after all test_user keep the test_v_guest.py name
1711
def test_guest_create(fastapi, caplog):
1812
caplog.set_level(logging.FATAL)
1913

QA/py/tools/dbBuildSQL.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Build the DB from scratch in EcoTaxa.
33
"""
4+
45
import os
56
import shutil
67
import socket
@@ -20,7 +21,6 @@
2021
if PG_HOST and PG_PORT:
2122
PG_PORT = int(PG_PORT)
2223
else:
23-
# pg_lib = "/usr/lib/postgresql/135/bin/" # ============ 124 passed, 1 skipped, 4 warnings in 223.88s (0:03:43) ============
2424
pg_lib = "/usr/lib/postgresql/14/bin/" # ============ 124 passed, 1 skipped, 4 warnings in 221.91s (0:03:41) ============
2525
pgctl_bin = join(pg_lib, "pg_ctl")
2626
initdb_bin = join(pg_lib, "initdb")

0 commit comments

Comments
 (0)