-
-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test/base example #190
Merged
Merged
Test/base example #190
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
f63c45c
Writing some initial tests for Map.py using pytest-qgis
zacdezgeo 05e0e88
Add proper registration of WMS provider
zacdezgeo e372fe6
wip to test add_layers functionality
zacdezgeo 0352924
Add python env file to use extlibs as pythonpath
alukach 9f2db44
Debug adding provider (wip)
zacdezgeo 088bc52
Base example test implemented
zacdezgeo b89df26
Update CI to authenticate to earthengine
zacdezgeo efd43cf
Add test to pythonpath
zacdezgeo e00ac73
Revert pytest call in CI
zacdezgeo a839ea9
Add pythonpath
zacdezgeo 85d8717
Simplify test execution in CI (wip)
zacdezgeo 99eeedb
Add future for CI dependencies
zacdezgeo d9508e8
Reorganized plugin code into a module
zacdezgeo 6926180
Add caching of dependencies and use pre-built qgis image
zacdezgeo 84d9515
Activate virtualenv to avoid system wide permissions error
zacdezgeo 5bbe63c
Update python version to use matrix strategy
zacdezgeo 49ab5db
Update python version to 3.9
zacdezgeo 2a4572a
Remove setup python
zacdezgeo 05e170f
Update base image to Kartoza
zacdezgeo 60c0e0b
Move to qgis/qgis image
zacdezgeo ba31920
Revert to configuring our own environment
zacdezgeo d17f75e
Move plugin files to ee_plugin module
zacdezgeo 6246b5b
Modify path for paver package to avoid nested ee_plugin
zacdezgeo 7483124
Add icons, i18n, and contrib to paver packaging
zacdezgeo c3d71fe
Merge branch 'master' into test/base-example
zacdezgeo 2973d87
Update path to ee_plugin module
zacdezgeo 7cb23ae
Add paver to dev requirements
zacdezgeo 82e9315
Bug 195/add vector layer (#196)
zacdezgeo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,4 @@ temp | |
venv | ||
.DS_Store | ||
htmlcov | ||
.coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
PYTHONPATH=${PYTHONPATH}:./extlibs:/Applications/QGIS-LTR.app/Contents/MacOS/lib/python3.9 | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"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" | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import ee | ||
from pytest import fixture | ||
from qgis.utils import plugins | ||
from PyQt5.QtCore import QSettings, QCoreApplication | ||
|
||
from ee_plugin.ee_plugin import GoogleEarthEnginePlugin | ||
|
||
|
||
@fixture(scope="session", autouse=True) | ||
def setup_ee(): | ||
"""Initialize the Earth Engine API.""" | ||
print("Initializing Earth Engine API...") | ||
ee.Initialize() | ||
ee.Authenticate(auth_mode="localhost", quiet=True) | ||
|
||
|
||
@fixture(scope="session", autouse=True) | ||
def load_ee_plugin(qgis_app, setup_ee): | ||
"""Load Earth Engine plugin and configure QSettings.""" | ||
|
||
# Set QSettings values required by the plugin | ||
QCoreApplication.setOrganizationName("QGIS") | ||
QCoreApplication.setApplicationName("QGIS Testing") | ||
QSettings().setValue("locale/userLocale", "en") | ||
|
||
# Initialize and register the plugin | ||
plugin = GoogleEarthEnginePlugin(qgis_app) | ||
plugins["ee_plugin"] = plugin | ||
plugin.check_version() | ||
yield qgis_app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from ee_plugin import Map | ||
|
||
|
||
def test_add_layer(): | ||
"""Test adding a layer to the map.""" | ||
import ee | ||
|
||
image = ee.Image("USGS/SRTMGL1_003") | ||
vis_params = { | ||
"min": 0, | ||
"max": 4000, | ||
"palette": ["006633", "E5FFCC", "662A00", "D8D8D8", "F5F5F5"], | ||
} | ||
|
||
# Add the layer to the map | ||
Map.addLayer(image, vis_params, "DEM") | ||
|
||
|
||
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." | ||
assert all( | ||
isinstance(coord, (float, int)) for coord in bounds | ||
), "Bounds coordinates are not numeric." | ||
|
||
|
||
def test_get_scale(): | ||
"""Test getting the map scale.""" | ||
scale = Map.getScale() | ||
assert scale > 0, "Scale should be a positive number." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import ee | ||
import pytest | ||
|
||
from ee_plugin import Map | ||
|
||
# initialize the Earth Engine API is required to use the ee.Geometry module | ||
# and runs before fixtures | ||
ee.Initialize() | ||
|
||
geometries = [ | ||
(ee.Geometry.Point([1.5, 1.5]), {"color": "1eff05"}, "point"), | ||
( | ||
ee.Geometry.LineString([[-35, -10], [35, -10], [35, 10], [-35, 10]]), | ||
{"color": "FF0000"}, | ||
"lineString", | ||
), | ||
( | ||
ee.Geometry.LinearRing( | ||
[[-35, -10], [35, -10], [35, 10], [-35, 10], [-35, -10]] | ||
), | ||
{"color": "ee38ff"}, | ||
"linearRing", | ||
), | ||
(ee.Geometry.Rectangle([-40, -20, 40, 20]), {"color": "ffa05c"}, "rectangle"), | ||
( | ||
ee.Geometry.Polygon([[[-5, 40], [65, 40], [65, 60], [-5, 60], [-5, 40]]]), | ||
{"color": "FF0000"}, | ||
"geodesic polygon", | ||
), | ||
( | ||
ee.Geometry( | ||
ee.Geometry.Polygon([[[-5, 40], [65, 40], [65, 60], [-5, 60], [-5, 40]]]), | ||
None, | ||
False, | ||
), | ||
{"color": "000000"}, | ||
"planar polygon", | ||
), | ||
] | ||
|
||
|
||
@pytest.mark.parametrize("geometry, vis_params, layer_name", geometries) | ||
def test_add_geometry_layer(geometry, vis_params, layer_name): | ||
Map.addLayer(geometry, vis_params, layer_name), "Layer added successfully" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't love hardcoding these paths into our repo but I think we can refine that later. These are simply for developer experience so will just be an annoyance for any plugin developers with differing paths.