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.
author decisions: add decision table and populate it
implemented task in airflow that allows for this and added unit tests for all the changes * ref: cern-sis/issues-inspire/issues/522
- Loading branch information
Showing
6 changed files
with
71 additions
and
75 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
38 changes: 0 additions & 38 deletions
38
workflows/plugins/hooks/backoffice/decision_management_hook.py
This file was deleted.
Oops, something went wrong.
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.
50 changes: 50 additions & 0 deletions
50
workflows/tests/cassettes/TestAuthorCreate.test_create_decision_on_curation_choice.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,50 @@ | ||
interactions: | ||
- request: | ||
body: '{"action": "create", "workflow_id": "ecaa62db-1326-43cf-8885-da96c544af42"}' | ||
headers: | ||
Accept: | ||
- application/json | ||
Accept-Encoding: | ||
- gzip, deflate | ||
Authorization: | ||
- Token 2e04111a61e8f5ba6ecec52af21bbb9e81732085 | ||
Connection: | ||
- keep-alive | ||
Content-Length: | ||
- '75' | ||
Content-Type: | ||
- application/json | ||
User-Agent: | ||
- python-requests/2.31.0 | ||
method: POST | ||
uri: http://host.docker.internal:8000/api/decisions/ | ||
response: | ||
body: | ||
string: '{"id":1,"action":"create","_created_at":"2024-08-19T15:13:28.514638Z","_updated_at":"2024-08-19T15:13:28.514646Z","user":"[email protected]","workflow":"ecaa62db-1326-43cf-8885-da96c544af42"}' | ||
headers: | ||
Allow: | ||
- GET, POST, HEAD, OPTIONS | ||
Content-Language: | ||
- en | ||
Content-Length: | ||
- '189' | ||
Content-Type: | ||
- application/json | ||
Cross-Origin-Opener-Policy: | ||
- same-origin | ||
Date: | ||
- Mon, 19 Aug 2024 15:13:28 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 |
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,40 +1,20 @@ | ||
from workflows.dags.author.author_create.shared_tasks import ( | ||
import pytest | ||
from dags.author.author_create.shared_tasks import ( | ||
create_decision_on_curation_choice, | ||
) | ||
|
||
|
||
def test_create_decision_on_curation_choice(): | ||
create_decision_on_curation_choice() | ||
|
||
|
||
# class TestMyTask(unittest.TestCase): | ||
# @patch("my_dag_module.some_dependency") | ||
# def test_my_task(self, mock_dependency): | ||
# # Arrange: Set up any necessary state or mock returns | ||
# mock_dependency.return_value = "expected_value" | ||
|
||
# # Act: Execute the task logic directly | ||
# result = my_task_function() | ||
|
||
# # Assert: Verify the results are as expected | ||
# self.assertEqual(result, "expected_output") | ||
|
||
|
||
# class TestMyDag(unittest.TestCase): | ||
# def setUp(self): | ||
# self.dagbag = DagBag() | ||
# self.dag = self.dagbag.get_dag(dag_id="my_dag_id") | ||
# self.task = self.dag.get_task("my_task_id") | ||
|
||
# def test_task_execution(self): | ||
# # You can simulate running the task | ||
# from airflow.models import TaskInstance | ||
# from airflow.utils.dates import days_ago | ||
|
||
# ti = TaskInstance(task=self.task, execution_date=days_ago(1)) | ||
|
||
# # You can optionally mock dependencies here | ||
|
||
# # Execute the task and assert the outcome | ||
# ti.run(ignore_ti_state=True) # Ignore previous task instance state | ||
# self.assertEqual(ti.state, State.SUCCESS) | ||
class TestAuthorCreate: | ||
context = { | ||
"params": { | ||
"workflow_id": "ecaa62db-1326-43cf-8885-da96c544af42", | ||
"data": { | ||
"value": "create", | ||
}, | ||
} | ||
} | ||
|
||
@pytest.mark.vcr() | ||
def test_create_decision_on_curation_choice(self): | ||
result = create_decision_on_curation_choice.function(**self.context) | ||
assert result.status_code == 201 |