Skip to content

Commit

Permalink
Moved layer-specific tests into layers.py
Browse files Browse the repository at this point in the history
  • Loading branch information
kcartier-wri committed Aug 9, 2024
1 parent f594c97 commit 981852d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
20 changes: 20 additions & 0 deletions tests/test_layers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ee
import pytest

from city_metrix.layers import (
Expand All @@ -22,6 +23,7 @@
UrbanLandUse,
WorldPop
)
from city_metrix.layers.layer import get_image_collection
from tests.fixtures.bbox_constants import BBOX_BRAZIL_LAURO_DE_FREITAS_1


Expand All @@ -47,6 +49,24 @@ def test_esa_world_cover():
assert count


def test_read_image_collection():
ic = ee.ImageCollection("ESA/WorldCover/v100")
data = get_image_collection(ic, BBOX_BRAZIL_LAURO_DE_FREITAS_1, 10, "test")

expected_crs = 32724
expected_x_dimension = 187
expected_y_dimension = 199

assert data.rio.crs == expected_crs
assert data.dims == {"x": expected_x_dimension, "y": expected_y_dimension}


def test_read_image_collection_scale():
ic = ee.ImageCollection("ESA/WorldCover/v100")
data = get_image_collection(ic, BBOX_BRAZIL_LAURO_DE_FREITAS_1, 100, "test")
assert data.dims == {"x": 19, "y": 20}


def test_high_land_surface_temperature():
data = HighLandSurfaceTemperature().get_data(BBOX_BRAZIL_LAURO_DE_FREITAS_1)
assert data.any()
Expand Down
20 changes: 0 additions & 20 deletions tests/test_methods.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import ee
import numpy as np

from city_metrix.layers.layer import get_image_collection
from .conftest import (
LARGE_ZONES,
ZONES,
Expand Down Expand Up @@ -58,21 +56,3 @@ def test_group_by_large_layer():
MockLargeLayer().groupby(LARGE_ZONES, layer=MockLargeGroupByLayer()).count()
)
assert all([count == {1: 50.0, 2: 50.0} for count in counts])


def test_read_image_collection():
ic = ee.ImageCollection("ESA/WorldCover/v100")
data = get_image_collection(ic, BBOX_BRAZIL_LAURO_DE_FREITAS_1, 10, "test")

expected_crs = 32724
expected_x_dimension = 187
expected_y_dimension = 199

assert data.rio.crs == expected_crs
assert data.dims == {"x": expected_x_dimension, "y": expected_y_dimension}


def test_read_image_collection_scale():
ic = ee.ImageCollection("ESA/WorldCover/v100")
data = get_image_collection(ic, BBOX_BRAZIL_LAURO_DE_FREITAS_1, 100, "test")
assert data.dims == {"x": 19, "y": 20}

0 comments on commit 981852d

Please sign in to comment.