Skip to content

Commit

Permalink
wip to test add_layers functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
zacdezgeo committed Jan 3, 2025
1 parent fc349fe commit cde4c37
Showing 1 changed file with 8 additions and 26 deletions.
34 changes: 8 additions & 26 deletions test/test_map.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import pytest
import ee
from qgis.core import QgsProviderRegistry, QgsProviderMetadata
from qgis.core import (
QgsProviderRegistry,
QgsProviderMetadata,
)
from qgis.utils import plugins
from PyQt5.QtCore import QSettings, QCoreApplication

Expand Down Expand Up @@ -29,8 +32,7 @@ def load_ee_plugin(qgis_app):
QSettings().setValue("locale/userLocale", "en")

# Initialize and register the plugin
iface = qgis_app
plugin = GoogleEarthEnginePlugin(iface)
plugin = GoogleEarthEnginePlugin(qgis_app)
plugins["ee_plugin"] = plugin
plugin.check_version()

Expand All @@ -41,7 +43,7 @@ def test_wms_metadata(qgis_app, load_ee_plugin):
assert "wms" in registry.providerList(), "WMS provider is not available!"


def test_add_layer(setup_ee, load_ee_plugin):
def test_add_layer(load_ee_plugin):
"""Test adding a layer to the map."""
image = ee.Image("USGS/SRTMGL1_003")
vis_params = {
Expand All @@ -54,21 +56,7 @@ def test_add_layer(setup_ee, load_ee_plugin):
Map.addLayer(image, vis_params, "DEM")


def test_set_center(setup_ee, qgis_app):
"""Test setting the map center."""
lon, lat, zoom = -121.753, 46.855, 9
Map.setCenter(lon, lat, zoom)

# Verify the center and zoom
center = Map.getCenter()
assert center.getInfo()["coordinates"] == [
lon,
lat,
], "Center coordinates do not match."
assert round(Map.getZoom()) == zoom, "Zoom level does not match."


def test_get_bounds(setup_ee, qgis_app):
def test_get_bounds():
"""Test getting the bounds of the map."""
bounds = Map.getBounds()
assert len(bounds) == 4, "Bounds do not have the expected format."
Expand All @@ -77,13 +65,7 @@ def test_get_bounds(setup_ee, qgis_app):
), "Bounds coordinates are not numeric."


def test_get_scale(setup_ee, qgis_app):
def test_get_scale():
"""Test getting the map scale."""
scale = Map.getScale()
assert scale > 0, "Scale should be a positive number."


def test_set_zoom(setup_ee, qgis_app):
"""Test setting the zoom level."""
Map.setZoom(10)
assert round(Map.getZoom()) == 10, "Zoom level was not set correctly."

0 comments on commit cde4c37

Please sign in to comment.