Skip to content

Commit

Permalink
use gh actions, switch to using pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
sckott committed Dec 11, 2020
1 parent 4bfdb7b commit 8e93164
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 51 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Python

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Install pygbif
run: make
- name: Tests
run: pytest
- name: Test coverage
if: matrix.python-version == '3.9'
run: |
python3 -m "pytest" --cov-report=xml --cov=pygbif test/
codecov
27 changes: 0 additions & 27 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ install: build
python3 setup.py install

test:
python3 -m "nose" -v --with-coverage --cover-package=pygbif
python3 -m "pytest" --cov-report term --cov=pygbif

docs:
cd docs;\
Expand Down
3 changes: 3 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[pytest]
python_files = test-*.py
testpaths = test
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ appdirs>=1.4.3
matplotlib
sphinx_issues
requests-cache
shapely>=1.5.13
vcrpy
20 changes: 10 additions & 10 deletions test/test-maps-map.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Tests for maps module - maps"""
from nose.tools import *
import pytest
import unittest
import vcr
import requests
Expand Down Expand Up @@ -48,14 +48,14 @@ def test_map_basisofrecord_list_class(self):
self.assertRegex(res.response.request.path_url, "HUMAN_OBSERVATION")
self.assertRegex(res.response.request.path_url, "LIVING_SPECIMEN")

@raises(ValueError)
def test_maps_fails_well(self):
"maps.map - fails well"
pygbif.maps.map(year=2300)
pygbif.maps.map(year="2010")
pygbif.maps.map(basisOfRecord="foobar")
pygbif.maps.map(format="foobar")
pygbif.maps.map(source="foobar")
pygbif.maps.map(srs="foobar")
pygbif.maps.map(bin="foobar")
pygbif.maps.map(style="foobar")
with pytest.raises(ValueError):
pygbif.maps.map(year=2300)
pygbif.maps.map(year="2010")
pygbif.maps.map(basisOfRecord="foobar")
pygbif.maps.map(format="foobar")
pygbif.maps.map(source="foobar")
pygbif.maps.map(srs="foobar")
pygbif.maps.map(bin="foobar")
pygbif.maps.map(style="foobar")
20 changes: 10 additions & 10 deletions test/test-occurrences-download_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_add_predicate(self):
req = GbifDownload("name", "email")
req.add_predicate("COUNTRY", "BE", "equals")
self.assertIsInstance(req.payload["predicate"]["predicates"], list)
self.assertEquals(len(req.payload["predicate"]["predicates"]), 1)
self.assertEqual(len(req.payload["predicate"]["predicates"]), 1)
self.assertIsInstance(req.payload["predicate"]["predicates"][0], dict)
self.assertDictEqual(
req.payload["predicate"]["predicates"][0],
Expand All @@ -69,16 +69,16 @@ def test_add_iterative_predicate(self):
req = GbifDownload("name", "email")
req.add_iterative_predicate("TAXONKEY", [3189866, 2498252])
self.assertIsInstance(req.payload["predicate"]["predicates"], list)
self.assertEquals(len(req.payload["predicate"]["predicates"]), 1)
self.assertEqual(len(req.payload["predicate"]["predicates"]), 1)
self.assertIsInstance(req.payload["predicate"]["predicates"][0], dict)

temp_pred = req.payload["predicate"]["predicates"][0]["predicates"]
self.assertIsInstance(temp_pred, list)
self.assertEquals(len(temp_pred), 2)
self.assertEqual(len(temp_pred), 2)
self.assertIsInstance(temp_pred[0], dict)

self.assertEquals(set(list(temp_pred[0].keys())), set(["key", "type", "value"]))
self.assertEquals(req.payload["predicate"]["predicates"][0]["type"], "or")
self.assertEqual(set(list(temp_pred[0].keys())), set(["key", "type", "value"]))
self.assertEqual(req.payload["predicate"]["predicates"][0]["type"], "or")

def test_add_geometry(self):
"""check predicate after adding a geometry"""
Expand All @@ -87,8 +87,8 @@ def test_add_geometry(self):
"POLYGON((-14.06 42.55, 9.84 38.27, -7.03 26.43, -14.06 42.55))"
)
self.assertIsInstance(req.payload["predicate"]["predicates"], list)
self.assertEquals(len(req.payload["predicate"]["predicates"]), 1)
self.assertEquals(
self.assertEqual(len(req.payload["predicate"]["predicates"]), 1)
self.assertEqual(
set(req.payload["predicate"]["predicates"][0].keys()),
set(["type", "geometry"]),
)
Expand Down Expand Up @@ -168,11 +168,11 @@ def test_multiple_predicates(self):
)
temp_pred = payload["predicate"]["predicates"]
self.assertIsInstance(temp_pred, list)
self.assertEquals(len(temp_pred), 2)
self.assertEqual(len(temp_pred), 2)
self.assertIsInstance(temp_pred[0], dict)
self.assertIsInstance(temp_pred[1], dict)
self.assertEquals(set(list(temp_pred[0].keys())), set(["key", "type", "value"]))
self.assertEquals(set(list(temp_pred[1].keys())), set(["key", "type", "value"]))
self.assertEqual(set(list(temp_pred[0].keys())), set(["key", "type", "value"]))
self.assertEqual(set(list(temp_pred[1].keys())), set(["key", "type", "value"]))

def test_alternative_main_type(self):
dl_key, payload = download(
Expand Down
6 changes: 3 additions & 3 deletions test/test-wkt_rewind.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Tests for utils module - wkt_rewind"""
from nose.tools import *
import pytest
import unittest
import re
from pygbif import utils
Expand All @@ -22,7 +22,7 @@ def test_wkt_rewind_digits(self):
self.assertIsInstance(out.string, str)


@raises(TypeError)
def test_wkt_rewind_fails_well():
"utils.wkt_rewind - fails well"
utils.wkt_rewind(x, digits="foo")
with pytest.raises(TypeError):
utils.wkt_rewind(x, digits="foo")

0 comments on commit 8e93164

Please sign in to comment.