Skip to content

Commit

Permalink
Merge a251d32 into 013307d
Browse files Browse the repository at this point in the history
  • Loading branch information
QuLogic committed Mar 5, 2020
2 parents 013307d + a251d32 commit f7500f2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def pytest_configure(config):
config.addinivalue_line("markers",
"network: mark tests that use the network.")
10 changes: 10 additions & 0 deletions tests/test_ctx.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
import numpy as np
import mercantile as mt
import pytest
import rasterio as rio
from contextily.tile import _calculate_zoom
from numpy.testing import assert_array_almost_equal
Expand All @@ -16,6 +17,7 @@
# Tile


@pytest.mark.network
def test_bounds2raster():
w, s, e, n = (
-106.6495132446289,
Expand Down Expand Up @@ -65,6 +67,7 @@ def test_bounds2raster():
assert_array_almost_equal(list(rtr.bounds), rtr_bounds)


@pytest.mark.network
def test_bounds2img():
w, s, e, n = (
-106.6495132446289,
Expand All @@ -86,6 +89,7 @@ def test_bounds2img():
assert img[200, 100, :].tolist() == [230, 225, 189]


@pytest.mark.network
def test_warp_tiles():
w, s, e, n = (
-106.6495132446289,
Expand All @@ -107,6 +111,7 @@ def test_warp_tiles():
assert wimg[200, 100, :].tolist() == [133, 130, 109]


@pytest.mark.network
def test_warp_img_transform():
w, s, e, n = ext = (
-106.6495132446289,
Expand Down Expand Up @@ -138,6 +143,7 @@ def test_howmany():
assert got == expected


@pytest.mark.network
def test_ll2wdw():
w, s, e, n = (
-106.6495132446289,
Expand Down Expand Up @@ -179,6 +185,7 @@ def test_autozoom():
# Place


@pytest.mark.network
def test_place():
expected_bbox = [-105.3014509, 39.9643513, -105.1780988, 40.094409]
expected_bbox_map = [
Expand Down Expand Up @@ -210,6 +217,7 @@ def test_place():
assert_array_almost_equal(loc.bbox_map, ax.images[0].get_extent())


@pytest.mark.network
def test_plot_map():
# Place as a search
loc = ctx.Place(SEARCH, zoom_adjust=ADJUST)
Expand All @@ -229,6 +237,7 @@ def test_plot_map():
# Plotting


@pytest.mark.network
def test_add_basemap():
# Plot boulder bbox as in test_place
x1, x2, y1, y2 = [
Expand Down Expand Up @@ -312,6 +321,7 @@ def test_add_basemap():
assert_array_almost_equal(ax.images[0].get_array().mean(), 179.79593258881636)


@pytest.mark.network
def test_basemap_attribution():
extent = (-11945319, -10336026, 2910477, 4438236)

Expand Down
3 changes: 3 additions & 0 deletions tests/test_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def test_providers():
ctx.bounds2img(w, s, e, n, 4, url=provider, ll=True)


@pytest.mark.network
def test_providers_callable():
# only testing the callable functionality to override a keyword, as we
# cannot test the actual providers that need an API key
Expand All @@ -64,12 +65,14 @@ def test_providers_callable():
assert ctx.providers.GeoportailFrance.maps["apikey"] == "choisirgeoportail"


@pytest.mark.network
def test_invalid_provider():
w, s, e, n = (-106.649, 25.845, -93.507, 36.494)
with pytest.raises(ValueError, match="The 'url' dict should at least contain"):
ctx.bounds2img(w, s, e, n, 4, url={"missing": "url"}, ll=True)


@pytest.mark.network
def test_provider_attribute_access():
provider = ctx.providers.OpenStreetMap.Mapnik
assert provider.name == "OpenStreetMap.Mapnik"
Expand Down

0 comments on commit f7500f2

Please sign in to comment.