-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:gee-community/pytest-gee into main
- Loading branch information
Showing
7 changed files
with
412 additions
and
2 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 |
---|---|---|
|
@@ -88,3 +88,4 @@ jobs: | |
file: ./coverage.xml | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
verbose: true | ||
files: ./coverage.xml |
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 |
---|---|---|
@@ -1,10 +1,15 @@ | ||
"""The init file of the package.""" | ||
from __future__ import annotations | ||
|
||
import os | ||
from pathlib import Path | ||
from typing import Union | ||
|
||
import ee | ||
import httplib2 | ||
|
||
from pytest_gee import utils | ||
|
||
__version__ = "0.2.0" | ||
__author__ = "Pierrick Rambaud" | ||
__email__ = "[email protected]" | ||
|
@@ -35,3 +40,18 @@ def init_ee_from_token(): | |
# if the user is in local development the authentication should | ||
# already be available | ||
ee.Initialize(http_transport=httplib2.Http()) | ||
|
||
|
||
def wait(task: Union[ee.batch.Task, str], timeout: int = 5 * 60) -> str: | ||
"""Wait until the selected process is finished or we reached timeout value. | ||
Args: | ||
task: name of the running task or the Task object itself. | ||
timeout: timeout in seconds. if set to 0 the parameter is ignored. default to 5 minutes. | ||
Returns: | ||
the final state of the task | ||
""" | ||
# just expose the utils function | ||
# this is compulsory as wait is also needed in the utils module | ||
return utils.wait(task, timeout) |
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,10 +1,38 @@ | ||
"""A pytest plugin to build a GEE environment for a test session.""" | ||
from __future__ import annotations | ||
|
||
import uuid | ||
from pathlib import Path | ||
|
||
import ee | ||
import pytest | ||
|
||
from . import utils | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def gee_hash(): | ||
"""Generate a unique hash for the test session.""" | ||
return uuid.uuid4().hex | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def gee_folder_root(): | ||
"""Link to the root folder of the connected account.""" | ||
return Path(ee.data.getAssetRoots()[0]["id"]) | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def gee_folder_structure(): | ||
"""The structure of the generated test folder.""" | ||
return {} | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def gee_test_folder(gee_hash, gee_folder_root, gee_folder_structure): | ||
"""Create a test folder for the duration of the test session.""" | ||
folder = utils.init_tree(gee_folder_structure, gee_hash, gee_folder_root) | ||
|
||
yield folder | ||
|
||
utils.delete_assets(folder, False) |
Oops, something went wrong.