Skip to content

Commit

Permalink
Use QGIS helper for installing plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
alukach committed Feb 14, 2025
1 parent 12ee9f4 commit d818103
Showing 1 changed file with 3 additions and 27 deletions.
30 changes: 3 additions & 27 deletions test/conftest.py
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

0 comments on commit d818103

Please sign in to comment.