From 209cf52d7abdb74f3310de36f99ef695b2a88700 Mon Sep 17 00:00:00 2001 From: DonHaul Date: Thu, 15 Aug 2024 17:39:18 +0200 Subject: [PATCH] tests --- workflows/Dockerfile | 3 +- workflows/tests/test_author_create_tasks.py | 42 ++++++++++++++++++++- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/workflows/Dockerfile b/workflows/Dockerfile index dbf8710c..b600cbec 100644 --- a/workflows/Dockerfile +++ b/workflows/Dockerfile @@ -5,5 +5,6 @@ WORKDIR /opt/airflow COPY --chown=airflow:root dags ./dags/ COPY --chown=airflow:root plugins ./plugins/ COPY --chown=airflow:root requirements.txt ./requirements.txt +COPY --chown=airflow:root requirements-test.txt ./requirements-test.txt -RUN pip install --no-cache-dir -r requirements.txt +RUN pip install --no-cache-dir -r requirements.txt -r requirements-test.txt diff --git a/workflows/tests/test_author_create_tasks.py b/workflows/tests/test_author_create_tasks.py index 8ba0f108..645ba1a1 100644 --- a/workflows/tests/test_author_create_tasks.py +++ b/workflows/tests/test_author_create_tasks.py @@ -1,2 +1,40 @@ -def create_decision_on_curation_choice(): - pass +from workflows.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)