diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 37127cb90f1d3d5882058d42ff41738e399a9cca..862ece7f7db2b252dac063cb1aca4aa3fb116382 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -15,6 +15,7 @@ test: before_script: - airflow db init - pip install -r requirements.txt + - pip install nose==1.3.7 - airflow connections add --conn-uri https://b2share-testing.fz-juelich.de/ default_b2share script: - ls @@ -23,4 +24,5 @@ test: - airflow dags list - airflow connections list - airflow dags test firsto 2021-08-18 + - nosetests diff --git a/tests/test_b2shareoperator.py b/tests/test_b2shareoperator.py new file mode 100644 index 0000000000000000000000000000000000000000..6d9adf2e4a0c04a2ec84ae57fd84c5e002e26727 --- /dev/null +++ b/tests/test_b2shareoperator.py @@ -0,0 +1,22 @@ +import unittest +from airflow.utils.state import State +from dags.b2shareoperator import B2ShareOperator +from airflow import DAG +from airflow.models.taskinstance import TaskInstance + +DEFAULT_DATE = '2019-10-03' +TEST_DAG_ID = 'test_my_custom_operator' + +class B2ShareOperatorTest(unittest.TestCase): + def setUp(self): + self.dag = DAG(TEST_DAG_ID, schedule_interval='@daily', default_args={'start_date' : DEFAULT_DATE}) + self.op = B2ShareOperator( + dag=self.dag, + task_id='test', + ) + self.ti = TaskInstance(task=self.op, execution_date=DEFAULT_DATE) + + def test_execute_no_trigger(self): + self.ti.run(ignore_ti_state=True) + assert self.ti.state == State.SUCCESS + # Assert something related to tasks results \ No newline at end of file diff --git a/tests/test_dag.py b/tests/test_dag.py new file mode 100644 index 0000000000000000000000000000000000000000..cfc812e234f28eaebe6112db78d43b02557dcf3d --- /dev/null +++ b/tests/test_dag.py @@ -0,0 +1,13 @@ +from airflow.models import DagBag +import unittest + +class TestADag(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.dagbag = DagBag() + + def test_dag_loaded(self): + dag = self.dagbag.get_dag(dag_id='firsto') + assert self.dagbag.import_errors == {} + assert dag is not None + assert len(dag.tasks) == 1 \ No newline at end of file