Skip to content

Commit

Permalink
Remove some tests about "roundtripping" a simple TI -- they don't mak…
Browse files Browse the repository at this point in the history
…e sense any more
  • Loading branch information
ashb committed Dec 19, 2024
1 parent 1e703c2 commit b22af18
Showing 1 changed file with 1 addition and 38 deletions.
39 changes: 1 addition & 38 deletions tests/callbacks/test_callback_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# under the License.
from __future__ import annotations

from datetime import datetime, timedelta
from datetime import datetime

import pytest

Expand All @@ -30,7 +30,6 @@
from airflow.providers.standard.operators.bash import BashOperator
from airflow.utils import timezone
from airflow.utils.state import State
from airflow.utils.types import DagRunType

pytestmark = pytest.mark.db_test

Expand Down Expand Up @@ -92,39 +91,3 @@ def test_taskcallback_to_json_with_start_date_and_end_date(self, session, create
json_str = input.to_json()
result = TaskCallbackRequest.from_json(json_str)
assert input == result

def test_simple_ti_roundtrip_exec_config_pod(self):
"""A callback request including a TI with an exec config with a V1Pod should safely roundtrip."""
from kubernetes.client import models as k8s

from airflow.callbacks.callback_requests import TaskCallbackRequest
from airflow.models import TaskInstance
from airflow.providers.standard.operators.bash import BashOperator

test_pod = k8s.V1Pod(metadata=k8s.V1ObjectMeta(name="hello", namespace="ns"))
op = BashOperator(task_id="hi", executor_config={"pod_override": test_pod}, bash_command="hi")
ti = TaskInstance(task=op, run_id="run1")
data = TaskCallbackRequest(full_filepath="hi", ti=ti).to_json()
actual = TaskCallbackRequest.from_json(data).ti.executor_config["pod_override"]
assert actual == test_pod

def test_simple_ti_roundtrip_dates(self, dag_maker):
"""A callback request including a TI with an exec config with a V1Pod should safely roundtrip."""
from airflow.callbacks.callback_requests import TaskCallbackRequest
from airflow.models import TaskInstance
from airflow.providers.standard.operators.bash import BashOperator

with dag_maker(schedule=timedelta(weeks=1), serialized=True):
op = BashOperator(task_id="hi", bash_command="hi")
dr = dag_maker.create_dagrun(
run_type=DagRunType.SCHEDULED,
external_trigger=True,
)
ti = TaskInstance(task=op, run_id=dr.run_id)
ti.refresh_from_db()
ti.set_state("SUCCESS")
start_date = ti.start_date
end_date = ti.end_date
data = TaskCallbackRequest(full_filepath="hi", ti=ti).to_json()
assert TaskCallbackRequest.from_json(data).ti.start_date == start_date
assert TaskCallbackRequest.from_json(data).ti.end_date == end_date

0 comments on commit b22af18

Please sign in to comment.