Added a test to check if the current files are about to expire (45 days from now)

Travis CI would run a monthly job and eventually report when it has failed, so actions can be done to refresh the files and "unbreak" the library.
This commit is contained in:
Bruno Bord 2019-10-04 11:06:53 +02:00
parent 1ddc115dc0
commit 06652c4310
No known key found for this signature in database
GPG Key ID: 9499EA6788BF80A1
2 changed files with 13 additions and 2 deletions

View File

@ -11,6 +11,7 @@
* Detect when a file has expired and raise a ``UserWarning``
* Add Travis CI badge on README.
* Warn user when there's a download error. Expiration date file won't be modified if at least one of the downloads has failed.
* Added a test to check if the current files are about to expire (45 days from now). Travis CI would run a monthly job and eventually report when it has failed, so actions can be done to refresh the files and "unbreak" the library.
## 0.0.2 (2019-08-23)

View File

@ -1,7 +1,7 @@
import mock
from datetime import date
from datetime import timedelta
from datetime import date, timedelta
from skyfield_data import get_skyfield_data_path
from skyfield_data.expiration_data import EXPIRATIONS
@mock.patch('skyfield_data.expirations.get_all')
@ -30,3 +30,13 @@ def test_expiration_deltat_yesterday(mocked_exp):
with mock.patch('warnings.warn') as mocked_warn:
get_skyfield_data_path()
assert mocked_warn.call_count == 1
def test_current_expiration_date():
# Filter all files that would expire in 45 days
expired = {
k: v for k, v in EXPIRATIONS.items()
if date.today() >= v - timedelta(days=45)
}
assert not expired, \
"{} files(s) are about to expire: {}".format(len(expired), expired)