Skip to content

Commit

Permalink
Add ORDER BY so test data is deterministic (#32489)
Browse files Browse the repository at this point in the history
  • Loading branch information
uranusjr authored Jul 10, 2023
1 parent b3c6e00 commit 8b4d6a8
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions tests/api_connexion/schemas/test_xcom_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import pickle

import pytest
from sqlalchemy import or_
from sqlalchemy import or_, select

from airflow.api_connexion.schemas.xcom_schema import (
XComCollection,
Expand Down Expand Up @@ -142,14 +142,15 @@ def test_serialize(self, create_xcom, session):
execution_date=self.time_2,
key="test_key_2",
)
xcom_models_query = session.query(XCom).filter(
or_(XCom.execution_date == self.time_1, XCom.execution_date == self.time_2)
)
xcom_models_queried = xcom_models_query.all()
xcom_models = session.scalars(
select(XCom)
.where(or_(XCom.execution_date == self.time_1, XCom.execution_date == self.time_2))
.order_by(XCom.dag_run_id)
).all()
deserialized_xcoms = xcom_collection_schema.dump(
XComCollection(
xcom_entries=xcom_models_queried,
total_entries=xcom_models_query.count(),
xcom_entries=xcom_models,
total_entries=len(xcom_models),
)
)
_compare_xcom_collections(
Expand Down

0 comments on commit 8b4d6a8

Please sign in to comment.