Skip to content

Commit

Permalink
#19 making tests work on python 2 and 3
Browse files Browse the repository at this point in the history
added python 3.4 for travis builds
  • Loading branch information
sckott committed May 19, 2016
1 parent 3715076 commit 9ee5980
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 30 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ sudo: false

python:
- "2.7"
- "3.4"

install:
- pip install 'requests>=2.7'
Expand Down
56 changes: 28 additions & 28 deletions test/test-occurrences-count.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@
import os
from pygbif import occurrences

brecord_res = [u'LITERATURE',
u'OBSERVATION',
u'LIVING_SPECIMEN',
u'UNKNOWN',
u'MATERIAL_SAMPLE',
u'PRESERVED_SPECIMEN',
u'MACHINE_OBSERVATION',
u'HUMAN_OBSERVATION',
u'FOSSIL_SPECIMEN']
brecord_res = ['LITERATURE',
'OBSERVATION',
'LIVING_SPECIMEN',
'UNKNOWN',
'MATERIAL_SAMPLE',
'PRESERVED_SPECIMEN',
'MACHINE_OBSERVATION',
'HUMAN_OBSERVATION',
'FOSSIL_SPECIMEN']

year_res = [u'1991',
u'1990',
u'1993',
u'1992',
u'1995',
u'1994',
u'1997',
u'1996',
u'1999',
u'1998',
u'2000']
year_res = ['1991',
'1990',
'1993',
'1992',
'1995',
'1994',
'1997',
'1996',
'1999',
'1998',
'2000']

def test_count():
"occurrences.count - basic test"
Expand All @@ -34,38 +34,38 @@ def test_count_basisofrecord():
res = occurrences.count_basisofrecord()
assert dict == res.__class__
assert 9 == len(res)
assert brecord_res == res.keys()
assert sorted(brecord_res) == sorted(res.keys())

def test_count_year():
"occurrences.count_year - basic test"
res = occurrences.count_year(year = '1990,2000')
assert dict == res.__class__
assert 11 == len(res)
assert year_res == res.keys()
assert sorted(year_res) == sorted(res.keys())

def test_count_datasets():
"occurrences.count_datasets - basic test"
res = occurrences.count_datasets(country = "DE")
assert dict == res.__class__
assert unicode == res.keys()[0].__class__
assert str == str(list(res.keys())[0]).__class__

def test_count_countries():
"occurrences.count_countries - basic test"
res = occurrences.count_countries(publishingCountry = "DE")
assert dict == res.__class__
assert unicode == res.keys()[0].__class__
assert int == res.values()[0].__class__
assert str == str(list(res.keys())[0]).__class__
assert int == list(res.values())[0].__class__

def test_count_schema():
"occurrences.count_schema - basic test"
res = occurrences.count_schema()
assert list == res.__class__
assert dict == res[0].__class__
assert "dimensions" == res[0].keys()[0]
assert "dimensions" == list(res[0].keys())[0]

def test_count_publishingcountries():
"occurrences.count_publishingcountries - basic test"
res = occurrences.count_publishingcountries(country = "DE")
assert dict == res.__class__
assert unicode == res.keys()[0].__class__
assert int == res.values()[0].__class__
assert str == str(list(res.keys())[0]).__class__
assert int == list(res.values())[0].__class__
4 changes: 3 additions & 1 deletion test/test-occurrences-search.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
import os
from pygbif import occurrences

keyz = ['count', 'facets', 'results', 'endOfRecords', 'limit', 'offset']

def test_search():
"occurrences.search - basic test"
res = occurrences.search(taxonKey = 3329049)
assert 'dict' == res.__class__.__name__
assert 6 == len(res)
assert [u'count', u'facets', u'results', u'endOfRecords', u'limit', u'offset'] == res.keys()
assert sorted(keyz) == sorted(res.keys())

def test_search_():
"occurrences.search - diff taxonKey"
Expand Down
2 changes: 1 addition & 1 deletion test/test-registry-nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def test_nodes():
assert dict == res.__class__
assert 2 == len(res)
assert 100 == len(res['data'])
assert ['meta', 'data'] == res.keys()
assert ['data', 'meta'] == sorted(res.keys())

def test_nodes_limit():
"limit param in registry.nodes"
Expand Down

0 comments on commit 9ee5980

Please sign in to comment.