Skip to content

Commit

Permalink
workflows: fixed set_schema and create_ticket_on_author_update
Browse files Browse the repository at this point in the history
  • Loading branch information
DonHaul committed Nov 26, 2024
1 parent 15ac6e1 commit 36456e4
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 2 deletions.
2 changes: 1 addition & 1 deletion workflows/dags/author/author_create/author_create_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def set_schema(**context):
workflow_management_hook.partial_update_workflow(
workflow_id=context["params"]["workflow_id"],
workflow_partial_update_data={
"data": {**context["params"]["data"], "$schema": schema}
"data": {**context["params"]["workflow"]["data"], "$schema": schema}
},
)

Expand Down
2 changes: 1 addition & 1 deletion workflows/dags/author/author_update/author_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def create_ticket_on_author_update(**context):

workflow_ticket_management_hook.create_ticket_entry(
workflow_id=context["params"]["workflow_id"],
ticket_type="author_update_user",
ticket_type="author_update_curation",
ticket_id=ticket_id,
)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
interactions:
- request:
body: '{"data": {"$schema": "https://inspirehep.net/schemas/records/authors.json",
"_collections": ["Authors"], "acquisition_source": {"datetime": "2024-11-18T11:34:19.809575",
"email": "[email protected]", "internal_uid": 50872, "method": "submitter",
"orcid": "0000-0002-7638-5686", "source": "submitter"}, "name": {"preferred_name":
"Third B", "value": "B, Third"}, "status": "active"}}'
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '393'
Content-Type:
- application/json
method: PATCH
uri: http://host.docker.internal:8001/api/workflows/authors/00000000-0000-0000-0000-000000001521/
response:
body:
string: '{"id":"00000000-0000-0000-0000-000000001521","tickets":[],"decisions":[],"data":{"$schema":"https://inspirehep.net/schemas/records/authors.json","_collections":["Authors"],"acquisition_source":{"datetime":"2024-11-18T11:34:19.809575","email":"[email protected]","internal_uid":50872,"method":"submitter","orcid":"0000-0002-7638-5686","source":"submitter"},"name":{"preferred_name":"Third
B","value":"B, Third"},"status":"active"},"workflow_type":"AUTHOR_CREATE","status":"running","_created_at":"2024-11-25T13:49:53.009000Z","_updated_at":"2024-11-26T14:13:56.571976Z"}'
headers:
Allow:
- GET, PUT, PATCH, DELETE, HEAD, OPTIONS
Content-Language:
- en
Content-Length:
- '580'
Content-Type:
- application/json
Cross-Origin-Opener-Policy:
- same-origin
Date:
- Tue, 26 Nov 2024 14:13:56 GMT
Referrer-Policy:
- same-origin
Server:
- WSGIServer/0.2 CPython/3.11.6
Vary:
- Accept, Accept-Language, Cookie, origin
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
status:
code: 200
message: OK
version: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
interactions:
- request:
body: '{"functional_category": "Author updates", "template": "curator_update_author",
"subject": "Update to author Third B on INSPIRE", "template_context": {"url":
"https://inspirebeta.net/authors/12345", "bibedit_url": "https://inspirebeta.net/record/12345",
"url_author_form": "https://inspirebeta.net/submissions/authors/12345"}, "caller_email":
"[email protected]"}'
headers:
Accept:
- application/vnd+inspire.record.raw+json
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '373'
Content-Type:
- application/json
method: POST
uri: https://inspirebeta.net/api/tickets/create
response:
body:
string: '{"ticket_id":"9e67066e8746d250225886640cbb3565","ticket_url":"https://cerntraining.service-now.com/nav_to.do?uri=/u_request_fulfillment.do?sys_id=9e67066e8746d250225886640cbb3565"}
'
headers:
access-control-allow-origin:
- '*'
access-control-expose-headers:
- Content-Type, ETag, Link, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset
alt-svc:
- h3=":443";ma=60;
content-length:
- '181'
content-type:
- application/json
date:
- Tue, 26 Nov 2024 15:00:51 GMT
server:
- gunicorn/19.10.0
x-proxy-backend:
- inspire-qa_hep-web_http
status:
code: 200
message: OK
- request:
body: '{"ticket_type": "author_update_curation", "ticket_id": "9e67066e8746d250225886640cbb3565",
"workflow": "00000000-0000-0000-0000-000000001521"}'
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '142'
Content-Type:
- application/json
method: POST
uri: http://host.docker.internal:8001/api/workflows/authors/tickets/
response:
body:
string: '{"id":3,"ticket_url":"https://cerntraining.service-now.com/nav_to.do?uri=/u_request_fulfillment.do?sys_id=9e67066e8746d250225886640cbb3565","workflow":"00000000-0000-0000-0000-000000001521","ticket_id":"9e67066e8746d250225886640cbb3565","ticket_type":"author_update_curation","_created_at":"2024-11-26T15:00:51.801217Z","_updated_at":"2024-11-26T15:00:51.801236Z"}'
headers:
Allow:
- GET, POST, HEAD, OPTIONS
Content-Language:
- en
Content-Length:
- '364'
Content-Type:
- application/json
Cross-Origin-Opener-Policy:
- same-origin
Date:
- Tue, 26 Nov 2024 15:00:51 GMT
Referrer-Policy:
- same-origin
Server:
- WSGIServer/0.2 CPython/3.11.6
Vary:
- Accept, Accept-Language, Cookie, origin
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
status:
code: 201
message: Created
version: 1
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ class TestAuthorCreateInit:
dag = dagbag.get_dag("author_create_initialization_dag")
context = base_context

@pytest.mark.vcr
def test_set_schema(self):
task = self.dag.get_task("set_schema")
task.execute(context=self.context)

@pytest.mark.vcr
def test_create_author_create_user_ticket(self):
task = self.dag.get_task("create_author_create_user_ticket")
Expand All @@ -79,3 +84,14 @@ def test_close_author_create_user_ticket(self):
def test_create_author_create_curation_ticket(self):
task = self.dag.get_task("create_author_create_curation_ticket")
task.execute(context=self.context)


class TestAuthorUpdate:
dag = dagbag.get_dag("author_update_dag")
context = base_context
context["params"]["workflow"]["data"]["control_number"] = "12345"

@pytest.mark.vcr
def test_create_ticket_on_author_update(self):
task = self.dag.get_task("create_ticket_on_author_update")
task.execute(context=self.context)

0 comments on commit 36456e4

Please sign in to comment.