This repository has been archived by the owner on Nov 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
airflow wf: close curation not working fix
- Loading branch information
Showing
9 changed files
with
131 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,7 +51,7 @@ jobs: | |
-v "$(pwd)"/tests:/opt/airflow/tests | ||
-v "$(pwd)"/requirements-test.txt:/opt/airflow/requirements-test.txt | ||
-v "$(pwd)"/data:/opt/airflow/data | ||
-v "$(pwd)"/scripts/variables/variables.json:/opt/airflow/variables.json | ||
-v "$(pwd)"/scripts:/opt/airflow/scripts | ||
-e AIRFLOW__CORE__EXECUTOR=CeleryExecutor | ||
-e AIRFLOW__DATABASE__SQL_ALCHEMY_CONN=postgresql+psycopg2://airflow:[email protected]:5432/airflow | ||
-e AIRFLOW__CELERY__RESULT_BACKEND=db+postgresql://airflow:[email protected]:5432/airflow | ||
|
@@ -61,4 +61,4 @@ jobs: | |
-e AIRFLOW__CORE__LOAD_EXAMPLES="false" | ||
-e AIRFLOW__API__AUTH_BACKENDS="airflow.api.auth.backend.basic_auth,airflow.api.auth.backend.session" | ||
registry.cern.ch/cern-sis/inspire/workflows@${{ needs.build.outputs.image-id }} | ||
bash -c "pip install -r requirements-test.txt && airflow db init && airflow variables import /opt/airflow/variables.json && pytest /opt/airflow/tests" | ||
bash -c "pip install -r requirements-test.txt && airflow db init && airflow connections import /opt/airflow/scripts/connections/connections.json && airflow variables import /opt/airflow/scripts/variables/variables.json && pytest /opt/airflow/tests" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from airflow.decorators import task | ||
from airflow.utils.trigger_rule import TriggerRule | ||
from hooks.backoffice.workflow_ticket_management_hook import ( | ||
WorkflowTicketManagementHook, | ||
) | ||
from hooks.inspirehep.inspire_http_hook import InspireHttpHook | ||
|
||
|
||
@task(trigger_rule=TriggerRule.NONE_FAILED_MIN_ONE_SUCCESS) | ||
def close_author_create_user_ticket(**context: dict) -> None: | ||
ticket_type = "author_create_user" | ||
ticket_id = WorkflowTicketManagementHook().get_ticket( | ||
workflow_id=context["params"]["workflow_id"], ticket_type=ticket_type | ||
)["ticket_id"] | ||
endpoint = "api/tickets/resolve" | ||
request_data = {"ticket_id": ticket_id} | ||
InspireHttpHook().call_api(endpoint=endpoint, data=request_data, method="POST") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
pytest | ||
coverage | ||
pytest-cov | ||
pytest-vcr==1.0.2 | ||
vcrpy==6.0.1 |
Empty file.
90 changes: 90 additions & 0 deletions
90
workflows/tests/cassettes/TestAuthorCreate.test_close_author_create_user_ticket.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
interactions: | ||
- request: | ||
body: null | ||
headers: | ||
Accept: | ||
- application/json | ||
Accept-Encoding: | ||
- gzip, deflate | ||
Authorization: | ||
- Token 2e04111a61e8f5ba6ecec52af21bbb9e81732085 | ||
Connection: | ||
- keep-alive | ||
Content-Type: | ||
- application/json | ||
User-Agent: | ||
- python-requests/2.31.0 | ||
method: GET | ||
uri: http://host.docker.internal:8000/api/workflow-ticket/f8301c06-8fa1-4124-845e-c270b910af5f/?ticket_type=author_create_user | ||
response: | ||
body: | ||
string: '{"id":1,"ticket_url":"https://cerntraining.service-now.com/nav_to.do?uri=/u_request_fulfillment.do?sys_id=656f2d17878c929095f833340cbb3531","ticket_id":"656f2d17878c929095f833340cbb3531","ticket_type":"author_create_user","workflow_id":"f8301c06-8fa1-4124-845e-c270b910af5f"}' | ||
headers: | ||
Allow: | ||
- GET, HEAD, OPTIONS | ||
Content-Language: | ||
- en | ||
Content-Length: | ||
- '275' | ||
Content-Type: | ||
- application/json | ||
Cross-Origin-Opener-Policy: | ||
- same-origin | ||
Date: | ||
- Wed, 21 Aug 2024 11:06:38 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 | ||
- request: | ||
body: ticket_id=656f2d17878c929095f833340cbb3531 | ||
headers: | ||
Accept: | ||
- application/vnd+inspire.record.raw+json | ||
Accept-Encoding: | ||
- gzip, deflate | ||
Authorization: | ||
- Bearer cZiS4W7K8sqyebkxQzpnSwuUKLr5Ne6qPfnoOAjP7M2IvHxQhKmwiCJpp2QC | ||
Connection: | ||
- keep-alive | ||
Content-Length: | ||
- '42' | ||
Content-Type: | ||
- application/x-www-form-urlencoded | ||
User-Agent: | ||
- python-requests/2.31.0 | ||
method: POST | ||
uri: https://inspirebeta.net/api/tickets/resolve | ||
response: | ||
body: | ||
string: '{"message":"Ticket resolved"} | ||
' | ||
headers: | ||
access-control-allow-origin: | ||
- '*' | ||
access-control-expose-headers: | ||
- Content-Type, ETag, Link, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset | ||
content-length: | ||
- '30' | ||
content-type: | ||
- application/json | ||
date: | ||
- Wed, 21 Aug 2024 11:06:39 GMT | ||
server: | ||
- gunicorn/19.10.0 | ||
x-proxy-backend: | ||
- inspire-qa_hep-web_http | ||
status: | ||
code: 200 | ||
message: OK | ||
version: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import pytest | ||
from dags.author.author_create.shared_tasks import ( | ||
close_author_create_user_ticket, | ||
) | ||
|
||
|
||
class TestAuthorCreate: | ||
context = { | ||
"params": { | ||
"workflow_id": "f8301c06-8fa1-4124-845e-c270b910af5f", | ||
"data": {"value": "reject", "create_ticket": False}, | ||
} | ||
} | ||
|
||
@pytest.mark.vcr() | ||
def test_close_author_create_user_ticket(self): | ||
close_author_create_user_ticket.function(**self.context) |