Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ repos:
^airflow-ctl.*\.py$|
^airflow-core/src/airflow/models/.*\.py$|
^airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_assets.py$|
^airflow-core/tests/unit/assets/test_manager.py$|
^task_sdk.*\.py$
pass_filenames: true
- id: update-supported-versions
Expand Down
23 changes: 16 additions & 7 deletions airflow-core/tests/unit/assets/test_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from unittest import mock

import pytest
from sqlalchemy import delete
from sqlalchemy import delete, func, select
from sqlalchemy.orm import Session

from airflow.assets.manager import AssetManager
Expand Down Expand Up @@ -105,8 +105,11 @@ def test_register_asset_change(self, session, dag_maker, mock_task_instance, tes
session.flush()

# Ensure we've created an asset
assert session.query(AssetEvent).filter_by(asset_id=asm.id).count() == 1
assert session.query(AssetDagRunQueue).count() == 2
assert (
session.scalar(select(func.count()).select_from(AssetEvent).where(AssetEvent.asset_id == asm.id))
== 1
)
assert session.scalar(select(func.count()).select_from(AssetDagRunQueue)) == 2

@pytest.mark.usefixtures("clear_assets")
def test_register_asset_change_with_alias(
Expand Down Expand Up @@ -145,8 +148,11 @@ def test_register_asset_change_with_alias(
session.flush()

# Ensure we've created an asset
assert session.query(AssetEvent).filter_by(asset_id=asm.id).count() == 1
assert session.query(AssetDagRunQueue).count() == 2
assert (
session.scalar(select(func.count()).select_from(AssetEvent).where(AssetEvent.asset_id == asm.id))
== 1
)
assert session.scalar(select(func.count()).select_from(AssetDagRunQueue)) == 2

def test_register_asset_change_no_downstreams(self, session, mock_task_instance):
asset_manager = AssetManager()
Expand All @@ -161,8 +167,11 @@ def test_register_asset_change_no_downstreams(self, session, mock_task_instance)
session.flush()

# Ensure we've created an asset
assert session.query(AssetEvent).filter_by(asset_id=asm.id).count() == 1
assert session.query(AssetDagRunQueue).count() == 0
assert (
session.scalar(select(func.count()).select_from(AssetEvent).where(AssetEvent.asset_id == asm.id))
== 1
)
assert session.scalar(select(func.count()).select_from(AssetDagRunQueue)) == 0

def test_register_asset_change_notifies_asset_listener(
self, session, mock_task_instance, testing_dag_bundle
Expand Down