1yangsh commented on code in PR #77446:
URL: https://github.com/apache/airflow/pull/77446#discussion_r4656330169
##########
providers/databricks/tests/unit/databricks/sensors/test_databricks_partition.py:
##########
@@ -130,14 +130,21 @@ def test_fail__generate_partition_query_with_missing_opts(
"airflow.providers.databricks.sensors.databricks_partition.DatabricksPartitionSensor"
"._check_table_partitions"
)
- def test_fail_poke(self, _check_table_partitions):
- partitions = "test"
- self.partition_sensor.partitions = partitions
- _check_table_partitions.return_value = False
- with pytest.raises(
- AirflowException, match=rf"Specified partition\(s\): {partitions}
were not found."
- ):
- self.partition_sensor.poke(context={})
+ @pytest.mark.parametrize("partition_result", [[], None, False])
+ def test_poke_returns_false_when_partition_not_found(self,
_check_table_partitions, partition_result):
+ _check_table_partitions.return_value = partition_result
+ assert self.partition_sensor.poke(context={}) is False
+
+ @patch(
+
"airflow.providers.databricks.sensors.databricks_partition.DatabricksPartitionSensor"
+ "._check_table_partitions"
+ )
+ def test_poke_keeps_waiting_until_partition_arrives(self,
_check_table_partitions):
+ _check_table_partitions.side_effect = [[], [], [[1]]]
+ assert self.partition_sensor.poke(context={}) is False
+ assert self.partition_sensor.poke(context={}) is False
+ assert self.partition_sensor.poke(context={}) is True
+ assert _check_table_partitions.call_count == 3
Review Comment:
Thanks, applied in 7a05c8f: the test now loops over the expected results
instead of repeating the assert.
---
Drafted-by: Claude Code (Opus 5.5) (no human review before posting)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]