Added basic tests, via tox and CI via Travis

This commit is contained in:
Bruno Bord 2019-09-22 17:59:06 +02:00
parent 2c715b5bea
commit 94225ce126
No known key found for this signature in database
GPG Key ID: 9499EA6788BF80A1
7 changed files with 71 additions and 1 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@ build/
*.egg-info/
__pycache__/
venv/
.tox/

25
.travis.yml Normal file
View File

@ -0,0 +1,25 @@
sudo: false
dist: xenial
language: python
install:
- pip install tox
script:
- tox -e $TOXENV
matrix:
fast_finish: true
include:
# Python version is just for the look on travis.
- python: 2.7
env: TOXENV=py27
- python: 3.5
env: TOXENV=py35
- python: 3.6
env: TOXENV=py36
- python: 3.7
env: TOXENV=py37
sudo: true

View File

@ -5,6 +5,8 @@
* Added a ``--check-only`` argument to ``download.py`` to display the expiration dates of the files currently on disk.
* Enable computation of the expiration date of the BSP file(s) on disk (requires to install the local repository using the [dev] option / See README for more information).
* Dropped compatibility with Python 3.3 and 3.4, as skyfield did.
* Added basic tests for the ``get_skyfield_data_path`` function using `tox`.
* Added automated tests through Travis CI.
## 0.0.2 (2019-08-23)

View File

@ -6,7 +6,8 @@ help:
@echo " * clean: remove all skyfield data from data directory."
@echo " * package: build python source package."
@echo ""
@echo " * install-dev: Install the requirements to execute download.py"
@echo " * install-dev: Install the requirements to switch to dev mode."
@echo " * test: Run tests using tox."
download:
python3 download.py
@ -19,3 +20,6 @@ package:
install-dev:
pip install -e .[dev]
test:
tox

View File

@ -36,6 +36,12 @@ setup_requires =
dev =
jplephem
numpy
tox
tests =
pytest
skyfield
mock
# ipdb
[bdist_wheel]
universal = 1

18
tests/test_get_path.py Normal file
View File

@ -0,0 +1,18 @@
import mock
from skyfield_data import get_skyfield_data_path
from skyfield.api import Loader
def test_load_no_cache(tmpdir):
with mock.patch('jplephem.spk.SPK.open'): # avoid naughty side-effects
with mock.patch('skyfield.iokit.download') as download_patched:
load = Loader(tmpdir.dirname)
load('de421.bsp')
assert download_patched.call_count == 1
@mock.patch('skyfield.iokit.download')
def test_load_using_cache(download_patched):
load = Loader(get_skyfield_data_path())
load('de421.bsp')
assert download_patched.call_count == 0

14
tox.ini Normal file
View File

@ -0,0 +1,14 @@
[tox]
envlist = py27,py35,py36,py37
[testenv]
commands =
pytest -s
deps =
.[tests]
[testenv:py33]
deps = .
commands = pip freeze -l