Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to testing files #319

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions biocompute/apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def post(self, request) -> Response:
data = request.data
rejected_requests = False
accepted_requests = False
if 'POST_api_objects_drafts_create' in request.data:
if 'POST_api_objects_draft_create' in request.data:
data = legacy_api_converter(request.data)

for index, object in enumerate(data):
Expand Down Expand Up @@ -506,12 +506,12 @@ class DraftsPublishApi(APIView):
properties={
"published_object_id": openapi.Schema(
type=openapi.TYPE_STRING,
description="BCO Object Draft ID.",
description="BCO Object ID to use for published object.",
example="http://127.0.0.1:8000/TEST_000001/1.0"
),
"object_id": openapi.Schema(
type=openapi.TYPE_STRING,
description="BCO Object ID to use for published object.",
description="BCO Object Draft ID to look up.",
example="http://127.0.0.1:8000/TEST_000001/DRAFT"
),
"delete_draft": openapi.Schema(
Expand All @@ -535,7 +535,16 @@ class DraftsPublishApi(APIView):
)

def post(self, request) -> Response:
if request.data[0]["object_id"] == \
validator = BcoValidator()
response_data = []
requester = request.user
data = request.data
rejected_requests = False
accepted_requests = False
if 'POST_api_objects_drafts_publish' in request.data:
data = legacy_api_converter(request.data)

if "object_id" in data[0] and data[0]["object_id"] == \
"http://127.0.0.1:8000/TEST_000001/DRAFT":
return Response(
status=status.HTTP_200_OK,
Expand All @@ -548,17 +557,8 @@ def post(self, request) -> Response:
}
}]
)
validator = BcoValidator()
response_data = []
requester = request.user
data = request.data
rejected_requests = False
accepted_requests = False
if 'POST_api_objects_drafts_publish' in request.data:
data = legacy_api_converter(request.data)


for index, object in enumerate(data):
# response_id = object["contents"].get("object_id", index)
response_id = object.get("object_id", index)
bco_instance = user_can_publish_bco(object, requester)

Expand Down
2 changes: 1 addition & 1 deletion biocompute/selectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def user_can_publish_bco(object: dict, user:User) -> Bco:
if the user is authorized to publish the specified BCO, `False`
otherwise. Returns `None` if the specified BCO does not exist.
"""

draft_deconstructed = object_id_deconstructor(object["object_id"])
published_deconstructed = []
if "published_object_id" in object:
Expand Down
6 changes: 3 additions & 3 deletions biocompute/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,10 +552,10 @@ def publish_draft(bco_instance: Bco, user: User, object: dict):
new_bco_instance = deepcopy(bco_instance)
new_bco_instance.id = None
new_bco_instance.state = "PUBLISHED"
contents= new_bco_instance.contents
if "published_object_id" in object:
new_bco_instance.object_id = object["published_object_id"]
else:
contents= new_bco_instance.contents
version = contents['provenance_domain']['version']
draft_deconstructed = object_id_deconstructor(object["object_id"])
draft_deconstructed[-1] = version
Expand All @@ -566,9 +566,9 @@ def publish_draft(bco_instance: Bco, user: User, object: dict):
timezone.now()
)
contents["etag"] = generate_etag(contents)
thingk = bco_score(bco_instance=new_bco_instance)
score = bco_score(bco_instance=new_bco_instance)

if object["delete_draft"] is True:
if "delete_draft" in object and object["delete_draft"] is True:
deleted = delete_draft(bco_instance=bco_instance, user=user)

return new_bco_instance
Expand Down
24 changes: 12 additions & 12 deletions config/fixtures/local_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
"created": "2022-02-07T17:36:05.872Z",
"modified": "2022-06-28T23:44:49.394Z",
"derived_from": [],
"derived_from": "",
"contributors": [
{
"contribution": [
Expand Down Expand Up @@ -1155,7 +1155,7 @@
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
"created": "2022-02-07T17:36:05.872Z",
"modified": "2022-06-28T23:44:49.394Z",
"derived_from": [],
"derived_from": "",
"contributors": [
{
"contribution": [
Expand Down Expand Up @@ -1388,7 +1388,7 @@
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
"created": "2022-02-07T17:36:05.872Z",
"modified": "2022-06-28T23:44:49.394Z",
"derived_from": [],
"derived_from": "",
"contributors": [
{
"contribution": [
Expand Down Expand Up @@ -1989,7 +1989,7 @@
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
"created": "2022-02-07T17:36:05.872Z",
"modified": "2022-06-28T23:44:49.394Z",
"derived_from": [],
"derived_from": "",
"contributors": [
{
"contribution": [
Expand Down Expand Up @@ -2222,7 +2222,7 @@
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
"created": "2022-02-07T17:36:05.872Z",
"modified": "2022-06-28T23:44:49.394Z",
"derived_from": [],
"derived_from": "",
"contributors": [
{
"contribution": [
Expand Down Expand Up @@ -2504,7 +2504,7 @@
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
"created": "2022-02-07T17:36:05.872Z",
"modified": "2022-06-28T23:44:49.394Z",
"derived_from": [],
"derived_from": "",
"contributors": [
{
"contribution": [
Expand Down Expand Up @@ -2737,7 +2737,7 @@
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
"created": "2022-02-07T17:36:05.872Z",
"modified": "2022-06-28T23:44:49.394Z",
"derived_from": [],
"derived_from": "",
"contributors": [
{
"contribution": [
Expand Down Expand Up @@ -3207,7 +3207,7 @@
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
"created": "2022-02-07T17:36:05.872Z",
"modified": "2022-06-28T23:44:49.394Z",
"derived_from": [],
"derived_from": "",
"contributors": [
{
"contribution": [
Expand Down Expand Up @@ -3440,7 +3440,7 @@
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
"created": "2022-02-07T17:36:05.872Z",
"modified": "2022-06-28T23:44:49.394Z",
"derived_from": [],
"derived_from": "",
"contributors": [
{
"contribution": [
Expand Down Expand Up @@ -3673,7 +3673,7 @@
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
"created": "2022-02-07T17:36:05.872Z",
"modified": "2022-06-28T23:44:49.394Z",
"derived_from": [],
"derived_from": "",
"contributors": [
{
"contribution": [
Expand Down Expand Up @@ -3906,7 +3906,7 @@
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
"created": "2022-02-07T17:36:05.872Z",
"modified": "2022-06-28T23:44:49.394Z",
"derived_from": [],
"derived_from": "",
"contributors": [
{
"contribution": [
Expand Down Expand Up @@ -4139,7 +4139,7 @@
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
"created": "2022-02-07T17:36:05.872Z",
"modified": "2022-06-28T23:44:49.394Z",
"derived_from": [],
"derived_from": "",
"contributors": [
{
"contribution": [
Expand Down
24 changes: 12 additions & 12 deletions config/fixtures/test_portal.json
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
"created": "2022-02-07T17:36:05.872Z",
"modified": "2022-06-28T23:44:49.394Z",
"derived_from": [],
"derived_from": "",
"contributors": [
{
"contribution": [
Expand Down Expand Up @@ -1077,7 +1077,7 @@
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
"created": "2022-02-07T17:36:05.872Z",
"modified": "2022-06-28T23:44:49.394Z",
"derived_from": [],
"derived_from": "",
"contributors": [
{
"contribution": [
Expand Down Expand Up @@ -1310,7 +1310,7 @@
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
"created": "2022-02-07T17:36:05.872Z",
"modified": "2022-06-28T23:44:49.394Z",
"derived_from": [],
"derived_from": "",
"contributors": [
{
"contribution": [
Expand Down Expand Up @@ -1911,7 +1911,7 @@
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
"created": "2022-02-07T17:36:05.872Z",
"modified": "2022-06-28T23:44:49.394Z",
"derived_from": [],
"derived_from": "",
"contributors": [
{
"contribution": [
Expand Down Expand Up @@ -2144,7 +2144,7 @@
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
"created": "2022-02-07T17:36:05.872Z",
"modified": "2022-06-28T23:44:49.394Z",
"derived_from": [],
"derived_from": "",
"contributors": [
{
"contribution": [
Expand Down Expand Up @@ -2426,7 +2426,7 @@
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
"created": "2022-02-07T17:36:05.872Z",
"modified": "2022-06-28T23:44:49.394Z",
"derived_from": [],
"derived_from": "",
"contributors": [
{
"contribution": [
Expand Down Expand Up @@ -2659,7 +2659,7 @@
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
"created": "2022-02-07T17:36:05.872Z",
"modified": "2022-06-28T23:44:49.394Z",
"derived_from": [],
"derived_from": "",
"contributors": [
{
"contribution": [
Expand Down Expand Up @@ -3129,7 +3129,7 @@
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
"created": "2022-02-07T17:36:05.872Z",
"modified": "2022-06-28T23:44:49.394Z",
"derived_from": [],
"derived_from": "",
"contributors": [
{
"contribution": [
Expand Down Expand Up @@ -3362,7 +3362,7 @@
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
"created": "2022-02-07T17:36:05.872Z",
"modified": "2022-06-28T23:44:49.394Z",
"derived_from": [],
"derived_from": "",
"contributors": [
{
"contribution": [
Expand Down Expand Up @@ -3595,7 +3595,7 @@
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
"created": "2022-02-07T17:36:05.872Z",
"modified": "2022-06-28T23:44:49.394Z",
"derived_from": [],
"derived_from": "",
"contributors": [
{
"contribution": [
Expand Down Expand Up @@ -3828,7 +3828,7 @@
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
"created": "2022-02-07T17:36:05.872Z",
"modified": "2022-06-28T23:44:49.394Z",
"derived_from": [],
"derived_from": "",
"contributors": [
{
"contribution": [
Expand Down Expand Up @@ -4061,7 +4061,7 @@
"license": "https://github.com/FDA-ARGOS/data.argosdb/blob/v0.4_Feb/LICENSE",
"created": "2022-02-07T17:36:05.872Z",
"modified": "2022-06-28T23:44:49.394Z",
"derived_from": [],
"derived_from": "",
"contributors": [
{
"contribution": [
Expand Down
29 changes: 15 additions & 14 deletions config/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,20 @@ def legacy_api_converter(data:dict) ->dict:
_, new_data = data.popitem()

if "draft_id" in new_data[0]:
return_data =[]
for object in new_data:
if "object_id" in object:
return_data.append({
"object_id": object["draft_id"],
"published_object_id": object["object_id"],
"delete_draft": object["delete_draft"]
})
else:
return_data.append({
"object_id": object["draft_id"],
"delete_draft": object["delete_draft"]
})
return_data =[]
for object in new_data:
if "object_id" in object:
return_data.append({
"object_id": object["draft_id"],
"published_object_id": object["object_id"],
"delete_draft": object["delete_draft"]
})
else:
return_data.append({
"object_id": object["draft_id"],
"delete_draft": object["delete_draft"]
})
return return_data

if "prefixes" in new_data[0]:
return_data =[]
Expand All @@ -74,7 +75,7 @@ def legacy_api_converter(data:dict) ->dict:
"description": prefix["description"]
})
return return_data

return new_data

def response_constructor(
Expand Down
Loading
Loading