Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AirFlow Unit Testing not working as described in the documentation: #39402

Closed
2 tasks done
camilla-storytel opened this issue May 4, 2024 · 1 comment
Closed
2 tasks done
Labels
kind:bug This is a clearly a bug kind:documentation needs-triage label for new issues that we didn't triage yet

Comments

@camilla-storytel
Copy link

What do you see as an issue?

Hi!
I am trying to unit test my DAGs by following this link in the AirFlow docs:

import pytest

from airflow.models import DagBag


@pytest.fixture()
def dagbag():
    return DagBag()


def test_dag_loaded(dagbag):
    dag = dagbag.get_dag(dag_id="hello_world")
    assert dagbag.import_errors == {}
    assert dag is not None
    assert len(dag.tasks) == 1

However, when I try to run this with pytest, I get this error:

../env/lib/python3.10/site-packages/sqlalchemy/engine/base.py:1910:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <sqlalchemy.dialects.sqlite.pysqlite.SQLiteDialect_pysqlite object at 0x105bb66b0>, cursor = <sqlite3.Cursor object at 0x15c56bf40>
statement = 'SELECT dag.dag_id AS dag_dag_id, dag.root_dag_id AS dag_root_dag_id, dag.is_paused AS dag_is_paused, dag.is_subdag AS...end, dag.next_dagrun_create_after AS dag_next_dagrun_create_after \nFROM dag \nWHERE dag.dag_id = ?\n LIMIT ? OFFSET ?'
parameters = ('long-tail-recommender-0.0.1', 1, 0), context = <sqlalchemy.dialects.sqlite.base.SQLiteExecutionContext object at 0x15c713a30>

    def do_execute(self, cursor, statement, parameters, context=None):
>       cursor.execute(statement, parameters)
E       sqlite3.OperationalError: no such table: dag

../env/lib/python3.10/site-packages/sqlalchemy/engine/default.py:736: OperationalError

The above exception was the direct cause of the following exception:

I suspect I am lacking some local setup, but I don't really know which one and there is no further guidance in the documentation.

Solving the problem

If someone could please help me figure out why I am missing the dag table and what the proper setup would look like, I will happily open a PR to improve the documentaiton.

Anything else

This occurs every time I run pytest on the unit test example.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@camilla-storytel camilla-storytel added kind:bug This is a clearly a bug kind:documentation needs-triage label for new issues that we didn't triage yet labels May 4, 2024
Copy link

boring-cyborg bot commented May 4, 2024

Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.

@apache apache locked and limited conversation to collaborators May 4, 2024
@Taragolis Taragolis converted this issue into discussion #39403 May 4, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
kind:bug This is a clearly a bug kind:documentation needs-triage label for new issues that we didn't triage yet
Projects
None yet
Development

No branches or pull requests

1 participant