rusackas commented on code in PR #39404:
URL: https://github.com/apache/superset/pull/39404#discussion_r3565299507
##########
tests/unit_tests/utils/test_date_parsing.py:
##########
@@ -254,3 +257,91 @@ def test_warning_suppression():
assert len(warnings_list) == 0 # Should suppress all format inference
warnings
assert pd.api.types.is_datetime64_any_dtype(df["date"]) # Should still
parse dates
+
+
+# ============================================================================
+# NEW TESTS FOR datetime_to_epoch() - Edge case coverage
+# ============================================================================
+
+
+def test_datetime_to_epoch_naive_at_epoch():
+ """Test naive datetime exactly at epoch returns 0.0"""
+ # Edge case: Datetime at epoch boundary
+ epoch_dt = datetime(1970, 1, 1, 0, 0, 0)
+ result = datetime_to_epoch(epoch_dt)
+ assert result == 0.0, f"Epoch datetime should be 0.0, got {result}"
+
+
+def test_datetime_to_epoch_naive_one_second_after():
+ """Test naive datetime 1 second after epoch"""
+ dt = datetime(1970, 1, 1, 0, 0, 1)
+ result = datetime_to_epoch(dt)
+ expected = 1000.0 # 1 second * 1000 ms
+ assert result == expected, f"Expected {expected}ms, got {result}ms"
Review Comment:
Good catch, agreed. I can't push directly since maintainer edits are
disabled on this PR, but here's the addition as a one-click suggestion:
```suggestion
assert result == expected, f"Expected {expected}ms, got {result}ms"
def test_datetime_to_epoch_naive_one_second_before():
"""Test naive datetime 1 second before epoch returns a negative value"""
dt = datetime(1969, 12, 31, 23, 59, 59)
result = datetime_to_epoch(dt)
expected = -1000.0 # 1 second before epoch, in ms
assert result == expected, f"Expected {expected}ms, got {result}ms"
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]