pierrejeambrun commented on code in PR #44795:
URL: https://github.com/apache/airflow/pull/44795#discussion_r1879877143
##########
tests/api_fastapi/core_api/routes/public/test_assets.py:
##########
@@ -607,6 +607,53 @@ def test_filtering(self, test_client, params,
total_entries, session):
assert response.status_code == 200
assert response.json()["total_entries"] == total_entries
+ @pytest.mark.parametrize(
+ "params, expected_ids, num_events",
+ [
+ # Test Case 1: Filtering with both timestamp_gte and timestamp_lte
set to the same date
+ (
+ {"timestamp_gte":
from_datetime_to_zulu_without_ms(DEFAULT_DATE), "timestamp_lte":
from_datetime_to_zulu_without_ms(DEFAULT_DATE)},
+ [1], # expected_ids for events exactly on DEFAULT_DATE
+ 3,
+ ),
+
+ # Test Case 2: Filtering events greater than or equal to a certain
timestamp and less than or equal to another
+ (
+ {"timestamp_gte":
from_datetime_to_zulu_without_ms(DEFAULT_DATE), "timestamp_lte":
from_datetime_to_zulu_without_ms(DEFAULT_DATE + timedelta(days=1))},
+ [1, 2], # expected_ids for events within the date range
+ 3,
+ ),
+
+ # Test Case 3: timestamp_gte later than timestamp_lte with no
events in range
+ (
+ {"timestamp_gte":
from_datetime_to_zulu_without_ms(DEFAULT_DATE + timedelta(days=1)),
"timestamp_lte": from_datetime_to_zulu_without_ms(DEFAULT_DATE -
timedelta(days=1))},
+ [], # expected_ids for events outside the range
+ 3,
+ ),
+
+ # Test Case 4: timestamp_gte earlier than timestamp_lte, allowing
events within the range
+ (
+ {"timestamp_gte":
from_datetime_to_zulu_without_ms(DEFAULT_DATE + timedelta(days=1)),
"timestamp_lte": from_datetime_to_zulu_without_ms(DEFAULT_DATE +
timedelta(days=2))},
+ [2, 3], # expected_ids for events within the date range
+ 3,
Review Comment:
If we always create 3 event, no need to parametrize it.
Also `expected_ids` should be at the end (it's the final assertion), while
`3` (the number of event we create should be at the beginning because it's part
of the initial `Arrange` phase. (timestamp_gte etc... should be in the middle
because it's the `Act` part of the test)
--
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]