def test_get_dag_run_by_id_empty(mock_get_dag_run_db): '''test that an empty dag_run_list will return None''' action_resource = ActionsIdResource() context.policy_engine = ShipyardPolicy() dag_id = 'test_dag_id' execution_date = 'test_execution_date' result = action_resource.get_dag_run_by_id(dag_id, execution_date) mock_get_dag_run_db.assert_called_once_with(dag_id, execution_date) assert result is None
def test_get_dag_run_by_id_notempty(): '''test that a nonempty dag_run_list will return the 1st dag in the list''' action_resource = ActionsIdResource() action_resource.get_dag_run_db = dag_runs_db dag_id = 'test_dag_id' execution_date = 'test_execution_date' result = action_resource.get_dag_run_by_id(dag_id, execution_date) assert result == { 'dag_id': 'did2', 'execution_date': DATE_ONE, 'state': 'FAILED', 'run_id': '99', 'external_trigger': 'something', 'start_date': DATE_ONE, 'end_date': DATE_ONE }