-
-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use QGIS helper for installing plugin
- Loading branch information
Showing
1 changed file
with
3 additions
and
27 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,18 @@ | ||
import ee | ||
from pytest import fixture | ||
from qgis.utils import plugins, isPluginLoaded | ||
from qgis.utils import isPluginLoaded, startPlugin | ||
from qgis.gui import QgisInterface | ||
from PyQt5.QtCore import QSettings, QCoreApplication | ||
|
||
from ee_plugin import ee_plugin, config | ||
|
||
|
||
@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 ee_config(): | ||
return config.EarthEngineConfig() | ||
|
||
|
||
@fixture(scope="session", autouse=True) | ||
def load_ee_plugin( | ||
qgis_iface: QgisInterface, | ||
setup_ee: None, | ||
ee_config: config.EarthEngineConfig, | ||
): | ||
def load_ee_plugin(qgis_iface: QgisInterface): | ||
"""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 = ee_plugin.GoogleEarthEnginePlugin(iface=qgis_iface, ee_config=ee_config) | ||
plugin.check_version() | ||
|
||
plugins["ee_plugin"] = plugin | ||
startPlugin("ee_plugin") | ||
assert isPluginLoaded("ee_plugin") | ||
yield qgis_iface |