-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
Bug: Data Freshness Validation Fails with Future Dates
The data freshness validation in test_api_now.py and test_api_period.py contains two flaws. It incorrectly allows future dates to pass, as negative time_diff.days (indicating future dates) still satisfy the time_diff.days <= 10 condition. Additionally, it uses datetime.now() (local time) for comparison against data.date.replace(tzinfo=None) (timezone-stripped UTC time), leading to inaccurate age calculations and potential test failures across different timezones.
tests/mmi/test_api_period.py#L457-L463
tickersnap/tests/mmi/test_api_period.py
Lines 457 to 463 in ae4eb19
| # validate data freshness (within last 10 days to account for weekends) | |
| now = datetime.now() | |
| data_date = data.date.replace(tzinfo=None) | |
| time_diff = now - data_date | |
| assert ( | |
| time_diff.days <= 10 | |
| ), f"Data seems too old: {data_date} (age: {time_diff.days} days)" |
tests/mmi/test_api_now.py#L505-L512
tickersnap/tests/mmi/test_api_now.py
Lines 505 to 512 in ae4eb19
| # validate data freshness (within last 10 days to account for weekends) | |
| now = datetime.now() | |
| data_date = data.date.replace(tzinfo=None) | |
| time_diff = now - data_date | |
| assert ( | |
| time_diff.days <= 10 | |
| ), f"Data seems too old: {data_date} (age: {time_diff.days} days)" |
Reactions are currently unavailable