Skip to content

Commit

Permalink
Debug adding provider (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
zacdezgeo committed Jan 7, 2025
1 parent 0352924 commit 9f2db44
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 16 deletions.
Binary file modified .coverage
Binary file not shown.
2 changes: 1 addition & 1 deletion .python.env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
PYTHONPATH=${PYTHONPATH}:./extlibs
PYTHONPATH=${PYTHONPATH}:./extlibs:/Applications/QGIS-LTR.app/Contents/MacOS/lib/python3.9
9 changes: 8 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
{
"python.envFile": "${workspaceFolder}/.python.env"
"python.envFile": "${workspaceFolder}/.python.env",
"terminal.integrated.env.osx": {
"PYTHONPATH": "${PYTHONPATH}:./extlibs:/Applications/QGIS-LTR.app/Contents/MacOS/lib/python3.9"
},
"python.testing.pytestEnabled": true,
"python.testing.pytestArgs": [
"test"
],
}
4 changes: 2 additions & 2 deletions Map.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ def addLayer(eeObject, visParams=None, name=None, shown=True, opacity=1.0):
>>> from ee_plugin import Map
>>> Map.addLayer(.....)
"""
from utils import add_or_update_ee_layer
from . import utils

add_or_update_ee_layer(eeObject, visParams, name, shown, opacity)
utils.add_or_update_ee_layer(eeObject, visParams, name, shown, opacity)


def centerObject(feature, zoom=None):
Expand Down
1 change: 1 addition & 0 deletions provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def __init__(self, *args, **kwargs):

# create WMS provider
self.wms = QgsProviderRegistry.instance().createProvider("wms", *args, **kwargs)
assert self.wms, f"Failed to create WMS provider: {args}, {kwargs}"

@classmethod
def description(cls):
Expand Down
3 changes: 0 additions & 3 deletions pytest.ini

This file was deleted.

1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ pytest==7.4.3 # pytest-qgis does not support pytest>=8
pytest-cov
pytest-qgis==2.1.0
pre-commit
pyqt5
Binary file added symbology-style.db
Binary file not shown.
19 changes: 10 additions & 9 deletions test/test_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,23 @@
from qgis.utils import plugins
from PyQt5.QtCore import QSettings, QCoreApplication

import Map
from ee_plugin import GoogleEarthEnginePlugin
from .. import Map
from ..ee_plugin import GoogleEarthEnginePlugin


@pytest.fixture(scope="module")
@pytest.fixture(scope="module", autouse=True)
def setup_ee():
"""Initialize the Earth Engine API."""
ee.Initialize()


@pytest.fixture(scope="module")
@pytest.fixture(scope="module", autouse=True)
def load_ee_plugin(qgis_app):
"""Load Earth Engine plugin and configure QSettings."""
# Ensure WMS provider is registered
registry = QgsProviderRegistry.instance()
if "wms" not in registry.providerList():
registry.createProvider("wms", "libwmsprovider.so")
metadata = QgsProviderMetadata("wms", "WMS Provider", "libwmsprovider.so")
registry.registerProvider(metadata)

Expand All @@ -37,13 +38,13 @@ def load_ee_plugin(qgis_app):
plugin.check_version()


def test_wms_metadata(qgis_app, load_ee_plugin):
"""Check WMS provider metadata."""
registry = QgsProviderRegistry.instance()
assert "wms" in registry.providerList(), "WMS provider is not available!"
# def test_wms_metadata():
# """Check WMS provider metadata."""
# registry = QgsProviderRegistry.instance()
# assert "wms" in registry.providerList(), "WMS provider is not available!"


def test_add_layer(load_ee_plugin):
def test_add_layer():
"""Test adding a layer to the map."""
image = ee.Image("USGS/SRTMGL1_003")
vis_params = {
Expand Down

0 comments on commit 9f2db44

Please sign in to comment.