Skip to content

Commit

Permalink
tests: tests for iobis#171 + more type checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushanand18 authored Dec 14, 2024
1 parent e68f183 commit 12900b1
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions pyobis/occurrences/test_occurrence.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ def test_occurrences_search():
query = occurrences.search(scientificname="Mola mola", size=size)
assert not query.data # the data is none after query building but before executing
query.execute()
assert size == len(query.data)
assert "Mola mola" == query.data.scientificName[0]
assert "dict" == query.data.__class__.__name__
assert 2 == len(query.data)
assert size == len(query.to_pandas())
assert "Mola mola" == query.to_pandas().scientificName[0]


@pytest.mark.vcr()
Expand All @@ -32,7 +34,7 @@ def test_occurrence_search_mof():
)
assert not query.data
query.execute()
assert "Abra alba" == query.data.scientificName[0]
assert "Abra alba" == query.to_pandas().scientificName[0]
assert requests.get(query.api_url).status_code == 200
assert requests.get(query.mapper_url).status_code == 200

Expand Down Expand Up @@ -83,6 +85,13 @@ def test_occurrences_grid():
assert requests.get(query.api_url).status_code == 200
assert not query.mapper_url

# check for KML formats that to_pandas function is not implemented
with pytest.raises(
NotImplementedError,
match="to_pandas method is not yet available for these query types.",
):
query.to_pandas()


@pytest.mark.vcr()
def test_occurrences_getpoints():
Expand Down Expand Up @@ -128,6 +137,14 @@ def test_occurrences_tile():
query = occurrences.tile(x=1.77, y=52.26, z=0.5, mvt=1, scientificname="Mola mola")
query.execute()
assert requests.get(query.api_url).status_code == 200

# check for MVT formats that to_pandas function is not implemented
with pytest.raises(
NotImplementedError,
match="to_pandas method is not yet available for these query types.",
):
query.to_pandas()

query = occurrences.tile(x=1.77, y=52.26, z=0.5, mvt=0, scientificname="Mola mola")
query.execute()
assert requests.get(query.api_url).status_code == 200
Expand Down

0 comments on commit 12900b1

Please sign in to comment.