Skip to content

Commit

Permalink
conftest update
Browse files Browse the repository at this point in the history
  • Loading branch information
atmorling committed Dec 3, 2024
1 parent e72146f commit 140fa74
Showing 1 changed file with 13 additions and 24 deletions.
37 changes: 13 additions & 24 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import geopandas as gpd
import pandas as pd
import pytest
from erclient.client import ERClientNotFound

import ecoscope
from ecoscope.base import Relocations
Expand All @@ -18,31 +17,20 @@ def pytest_configure(config):

os.makedirs("tests/outputs", exist_ok=True)

try:
EE_ACCOUNT = os.getenv("EE_ACCOUNT")
EE_PRIVATE_KEY_DATA = os.getenv("EE_PRIVATE_KEY_DATA")
if EE_ACCOUNT and EE_PRIVATE_KEY_DATA:
ee.Initialize(credentials=ee.ServiceAccountCredentials(EE_ACCOUNT, key_data=EE_PRIVATE_KEY_DATA))
else:
ee.Initialize()
pytest.earthengine = True
except Exception:
pytest.earthengine = False
warnings.warn(Warning("Earth Engine can not be initialized. Skipping related tests..."))

try:
pytest.earthranger = ecoscope.io.EarthRangerIO(
server=os.getenv("ER_SERVER", "https://mep-dev.pamdas.org"),
username=os.getenv("ER_USERNAME"),
password=os.getenv("ER_PASSWORD"),
).login()
if not pytest.earthranger:
warnings.warn(Warning("EarthRanger_IO can not be initialized. Skipping related tests..."))
except ERClientNotFound:
pytest.earthranger = False
warnings.warn(Warning("EarthRanger_IO can not be initialized. Skipping related tests..."))
if config.inicfg.get("markers") == ["io"]:
try:
EE_ACCOUNT = os.getenv("EE_ACCOUNT")
EE_PRIVATE_KEY_DATA = os.getenv("EE_PRIVATE_KEY_DATA")
if EE_ACCOUNT and EE_PRIVATE_KEY_DATA:
ee.Initialize(credentials=ee.ServiceAccountCredentials(EE_ACCOUNT, key_data=EE_PRIVATE_KEY_DATA))
else:
ee.Initialize()
pytest.earthengine = True
except Exception:
warnings.warn(Warning("Earth Engine can not be initialized."))


@pytest.mark.io
@pytest.fixture(scope="session")
def er_io():
ER_SERVER = "https://mep-dev.pamdas.org"
Expand All @@ -59,6 +47,7 @@ def er_io():
return er_io


@pytest.mark.io
@pytest.fixture(scope="session")
def er_events_io():
ER_SERVER = "https://mep-dev.pamdas.org"
Expand Down

0 comments on commit 140fa74

Please sign in to comment.