From 53a420aa57af01bc641e4dc1ca79878241b26a12 Mon Sep 17 00:00:00 2001 From: Ghislain Vieilledent Date: Wed, 29 May 2024 09:38:14 +1100 Subject: [PATCH] Modifying tests --- docsrc/articles.rst | 2 +- docsrc/index.rst | 13 ++-------- docsrc/indices.rst | 1 - .../fcc.png | Bin .../large_countries.org} | 0 .../large_countries.rst} | 0 .../large_countries_1.org} | 0 .../large_countries_2.org} | 0 docsrc/python_api.rst | 7 +++++ docsrc/python_api/functions.rst | 3 +++ docsrc/reference.rst | 12 --------- geefcc/__init__.py | 2 +- test/test_get_fcc.py | 8 +++--- test/test_import.py | 24 ++++++++++++++++++ 14 files changed, 42 insertions(+), 30 deletions(-) rename docsrc/notebooks/{large_country => large_countries}/fcc.png (100%) rename docsrc/notebooks/{large_country/large_country.org => large_countries/large_countries.org} (100%) rename docsrc/notebooks/{large_country/large_country.rst => large_countries/large_countries.rst} (100%) rename docsrc/notebooks/{large_country/large_country_1.org => large_countries/large_countries_1.org} (100%) rename docsrc/notebooks/{large_country/large_country_2.org => large_countries/large_countries_2.org} (100%) create mode 100644 docsrc/python_api.rst create mode 100644 docsrc/python_api/functions.rst delete mode 100644 docsrc/reference.rst create mode 100644 test/test_import.py diff --git a/docsrc/articles.rst b/docsrc/articles.rst index b85c86c..c99c312 100644 --- a/docsrc/articles.rst +++ b/docsrc/articles.rst @@ -5,5 +5,5 @@ Articles :maxdepth: 1 notebooks/get_started/get_started.ipynb - notebooks/large_country/large_country + notebooks/large_countries/large_countries diff --git a/docsrc/index.rst b/docsrc/index.rst index 03afe92..f2b6511 100644 --- a/docsrc/index.rst +++ b/docsrc/index.rst @@ -1,23 +1,14 @@ .. include:: ../README.rst - -Table of contents -================= .. toctree:: + :hidden: :maxdepth: 2 Home notebooks/get_started/get_started articles - reference + python_api indices changelog license -Indices and tables ------------------- - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` - diff --git a/docsrc/indices.rst b/docsrc/indices.rst index d46b839..c087fa8 100644 --- a/docsrc/indices.rst +++ b/docsrc/indices.rst @@ -2,5 +2,4 @@ Indices and tables ================== * :ref:`genindex` -* :ref:`modindex` * :ref:`search` diff --git a/docsrc/notebooks/large_country/fcc.png b/docsrc/notebooks/large_countries/fcc.png similarity index 100% rename from docsrc/notebooks/large_country/fcc.png rename to docsrc/notebooks/large_countries/fcc.png diff --git a/docsrc/notebooks/large_country/large_country.org b/docsrc/notebooks/large_countries/large_countries.org similarity index 100% rename from docsrc/notebooks/large_country/large_country.org rename to docsrc/notebooks/large_countries/large_countries.org diff --git a/docsrc/notebooks/large_country/large_country.rst b/docsrc/notebooks/large_countries/large_countries.rst similarity index 100% rename from docsrc/notebooks/large_country/large_country.rst rename to docsrc/notebooks/large_countries/large_countries.rst diff --git a/docsrc/notebooks/large_country/large_country_1.org b/docsrc/notebooks/large_countries/large_countries_1.org similarity index 100% rename from docsrc/notebooks/large_country/large_country_1.org rename to docsrc/notebooks/large_countries/large_countries_1.org diff --git a/docsrc/notebooks/large_country/large_country_2.org b/docsrc/notebooks/large_countries/large_countries_2.org similarity index 100% rename from docsrc/notebooks/large_country/large_country_2.org rename to docsrc/notebooks/large_countries/large_countries_2.org diff --git a/docsrc/python_api.rst b/docsrc/python_api.rst new file mode 100644 index 0000000..a6647d6 --- /dev/null +++ b/docsrc/python_api.rst @@ -0,0 +1,7 @@ +Python API +********** + +.. toctree:: + :maxdepth: 2 + + python_api/functions.rst diff --git a/docsrc/python_api/functions.rst b/docsrc/python_api/functions.rst new file mode 100644 index 0000000..4f98277 --- /dev/null +++ b/docsrc/python_api/functions.rst @@ -0,0 +1,3 @@ +.. autofunction:: geefcc.get_fcc +.. autofunction:: geefcc.sum_raster_bands +.. autofunction:: geefcc.make_dir diff --git a/docsrc/reference.rst b/docsrc/reference.rst deleted file mode 100644 index 446007b..0000000 --- a/docsrc/reference.rst +++ /dev/null @@ -1,12 +0,0 @@ -Python API -********** - -get_fcc -======= - -.. autofunction:: geefcc.get_fcc - -sum_raster_bands -================ - -.. autofunction:: geefcc.sum_raster_bands diff --git a/geefcc/__init__.py b/geefcc/__init__.py index 09c1758..96ad01d 100644 --- a/geefcc/__init__.py +++ b/geefcc/__init__.py @@ -15,7 +15,7 @@ from .ee_initialize import ee_initialize from .get_fcc import get_fcc from .sum_raster_bands import sum_raster_bands -from . import misc +from .misc import make_dir # GDAL exceptions gdal.UseExceptions() diff --git a/test/test_get_fcc.py b/test/test_get_fcc.py index cea5a3c..9d2cace 100644 --- a/test/test_get_fcc.py +++ b/test/test_get_fcc.py @@ -3,7 +3,7 @@ # Import import os -from geefcc import get_fcc, ee_initialize +import geefcc as gf # "EARTHENGINE_TOKEN" for GitHub actions # https://github.com/gee-community/geemap/discussions/1341 @@ -13,7 +13,7 @@ # with the name EARTHENGINE_TOKEN. # Initialize GEE -ee_initialize( +gf.ee_initialize( token_name="EARTHENGINE_TOKEN", project="forestatrisk", opt_url="https://earthengine-highvolume.googleapis.com") @@ -21,7 +21,7 @@ def test_get_fcc_extent_tmf(): """Testing get_fcc().""" - get_fcc( + gf.get_fcc( # Extent for Reunion Island aoi=(55.21625137, -21.38986015, 55.83736038, -20.87180519), buff=0.08983152841195216, @@ -35,7 +35,7 @@ def test_get_fcc_extent_tmf(): def test_get_fcc_extent_gfc(): """Testing get_fcc().""" - get_fcc( + gf.get_fcc( # Extent for Reunion Island aoi=(55.21625137, -21.38986015, 55.83736038, -20.87180519), buff=0.08983152841195216, diff --git a/test/test_import.py b/test/test_import.py new file mode 100644 index 0000000..9073fae --- /dev/null +++ b/test/test_import.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# ============================================================================== +# author :Ghislain Vieilledent +# email :ghislain.vieilledent@cirad.fr, ghislainv@gmail.com +# web :https://ecology.ghislainv.fr +# python_version :>=2.7 +# license :GPLv3 +# ============================================================================== + + +# test_import +def test_import(): + """Test import.""" + imp = True + try: + import geefcc + except ImportError: + imp = False + assert imp is True + + +# End