From 8268e2c5aa585cde8c5a36ac046897d39b7584f1 Mon Sep 17 00:00:00 2001 From: kamangir Date: Mon, 29 Jul 2024 18:33:02 -0700 Subject: [PATCH] bashtest refactors - kamangir/bolt#746 --- blue_geo/.abcli/catalog/browse.sh | 9 +-- blue_geo/.abcli/catalog/generic/query.sh | 4 ++ blue_geo/.abcli/tests/catalog.sh | 59 +++++++++++++++++++ ...ms_area.sh => catalog_query_firms_area.sh} | 7 ++- blue_geo/.abcli/tests/datacube_catalog.sh | 6 -- blue_geo/.abcli/tests/datacube_get.sh | 15 ++++- blue_geo/.abcli/tests/generic.sh | 8 +++ blue_geo/__init__.py | 2 +- blue_geo/config.env | 4 +- blue_geo/env.py | 5 ++ blue_geo/tests/assets.py | 3 +- .../{test_build_README.py => test_README.py} | 0 blue_geo/tests/test_env.py | 1 + 13 files changed, 104 insertions(+), 19 deletions(-) create mode 100644 blue_geo/.abcli/tests/catalog.sh rename blue_geo/.abcli/tests/{datacube_firms_area.sh => catalog_query_firms_area.sh} (69%) delete mode 100644 blue_geo/.abcli/tests/datacube_catalog.sh create mode 100644 blue_geo/.abcli/tests/generic.sh rename blue_geo/tests/{test_build_README.py => test_README.py} (100%) diff --git a/blue_geo/.abcli/catalog/browse.sh b/blue_geo/.abcli/catalog/browse.sh index ab10abf0..06db5975 100644 --- a/blue_geo/.abcli/catalog/browse.sh +++ b/blue_geo/.abcli/catalog/browse.sh @@ -3,14 +3,15 @@ function blue_geo_catalog_browse() { local options=$1 + local catalog=$(abcli_option "$options" $blue_geo_catalog_list firms) + if [ $(abcli_option_int "$options" help 0) == 1 ]; then - abcli_show_usage "@catalog browse$ABCUL$ABCUL[]" \ - "browse ." + for catalog in $(echo $blue_geo_catalog_list | tr , " "); do + blue_geo_catalog_browse_${catalog} "$@" + done return fi - local catalog=$(abcli_option "$options" $blue_geo_catalog_list firms) - abcli_log "@catalog: browsing $catalog ..." blue_geo_catalog_browse_${catalog} "${@:2}" } diff --git a/blue_geo/.abcli/catalog/generic/query.sh b/blue_geo/.abcli/catalog/generic/query.sh index f7571b42..a14e4424 100644 --- a/blue_geo/.abcli/catalog/generic/query.sh +++ b/blue_geo/.abcli/catalog/generic/query.sh @@ -39,3 +39,7 @@ function blue_geo_catalog_query_generic() { function blue_geo_catalog_query_generic_generic() { : # no query available. } + +function blue_geo_catalog_browse_generic() { + : # no browse available. +} diff --git a/blue_geo/.abcli/tests/catalog.sh b/blue_geo/.abcli/tests/catalog.sh new file mode 100644 index 00000000..83f9aa93 --- /dev/null +++ b/blue_geo/.abcli/tests/catalog.sh @@ -0,0 +1,59 @@ +#! /usr/bin/env bash + +function test_blue_geo_catalog_browse() { + local options=$1 + + local catalog + for catalog in $(echo $blue_geo_catalog_list | tr , " "); do + abcli_eval ,$options \ + blue_geo catalog browse $catalog + [[ $? -ne 0 ]] && return 1 + done + + return 0 +} + +function test_blue_geo_catalog_get_list_of_collections() { + local options=$1 + + local catalog + for catalog in $(echo $blue_geo_catalog_list | tr , " "); do + abcli_eval ,$options \ + blue_geo catalog get \ + list_of_collections \ + --catalog $catalog \ + --delim , \ + --log 0 + [[ $? -ne 0 ]] && return 1 + done + + return 0 +} + +function test_blue_geo_catalog_list() { + local options=$1 + + abcli_eval ,$options \ + blue_geo catalog list +} + +function test_blue_geo_catalog_query() { + local options=$1 + + local catalog + for catalog in $(echo $blue_geo_catalog_list | tr , " "); do + local object_name="bashtest-$(abcli_string_timestamp)" + + abcli_eval ,$options \ + blue_geo catalog query firms \ + ingest \ + $object_name + [[ $? -ne 0 ]] && return 1 + + abcli_assert \ + $(blue_geo datacube query read len $object_name) \ + 1 + [[ $? -ne 0 ]] && return 1 + done + return 0 +} diff --git a/blue_geo/.abcli/tests/datacube_firms_area.sh b/blue_geo/.abcli/tests/catalog_query_firms_area.sh similarity index 69% rename from blue_geo/.abcli/tests/datacube_firms_area.sh rename to blue_geo/.abcli/tests/catalog_query_firms_area.sh index 8629cc80..4bc972f0 100644 --- a/blue_geo/.abcli/tests/datacube_firms_area.sh +++ b/blue_geo/.abcli/tests/catalog_query_firms_area.sh @@ -1,19 +1,20 @@ #! /usr/bin/env bash -function test_blue_geo_datacube_firms_area() { +function test_blue_geo_catalog_query_firms_area() { local options=$1 local object_name=firms-$(abcli_string_timestamp_short) blue_geo datacube query firms_area \ ingest $object_name - \ - --date 2024-07-18 + --date 2024-07-20 abcli_assert \ $(blue_geo datacube query read len $object_name) \ 1 + [[ $? -ne 0 ]] && return 1 abcli_assert \ $(blue_geo datacube query read - $object_name) \ - datacube-firms_area-world-MODIS_NRT-2024-07-18-1 + $BLUE_GEO_TEST_DATACUBE_FIRMS_AREA } diff --git a/blue_geo/.abcli/tests/datacube_catalog.sh b/blue_geo/.abcli/tests/datacube_catalog.sh deleted file mode 100644 index 0c8ebe32..00000000 --- a/blue_geo/.abcli/tests/datacube_catalog.sh +++ /dev/null @@ -1,6 +0,0 @@ -#! /usr/bin/env bash - -function test_blue_geo_datacube_catalog() { - abcli_eval dryrun=$do_dryrun \ - blue_geo datacube list catalogs -} diff --git a/blue_geo/.abcli/tests/datacube_get.sh b/blue_geo/.abcli/tests/datacube_get.sh index 11536f8f..c48b8380 100644 --- a/blue_geo/.abcli/tests/datacube_get.sh +++ b/blue_geo/.abcli/tests/datacube_get.sh @@ -3,27 +3,36 @@ function test_blue_geo_datacube_get_catalog() { abcli_assert \ $(blue_geo_datacube_get catalog void) \ + void + [[ $? -ne 0 ]] && return 1 + + abcli_assert \ + $(blue_geo_datacube_get catalog xyz) \ unknown-catalog + [[ $? -ne 0 ]] && return 1 abcli_assert \ $(blue_geo_datacube_get catalog datacube-generic) \ generic + [[ $? -ne 0 ]] && return 1 abcli_assert \ - $(blue_geo_datacube_get catalog datacube-firms_area-world-MODIS_NRT-2024-07-20-1) \ - firms_area + $(blue_geo_datacube_get catalog $BLUE_GEO_TEST_DATACUBE_FIRMS_AREA) \ + firms } function test_blue_geo_datacube_get_template() { abcli_assert \ $(blue_geo_datacube_get template unknown-catalog) \ unknown-template + [[ $? -ne 0 ]] && return 1 abcli_assert \ $(blue_geo_datacube_get template generic) \ unknown-template + [[ $? -ne 0 ]] && return 1 abcli_assert \ - $(blue_geo_datacube_get template firms_area) \ + $(blue_geo_datacube_get template $BLUE_GEO_TEST_DATACUBE_FIRMS_AREA) \ $BLUE_GEO_FIRMS_AREA_QGIS_TEMPLATE } diff --git a/blue_geo/.abcli/tests/generic.sh b/blue_geo/.abcli/tests/generic.sh new file mode 100644 index 00000000..22bba915 --- /dev/null +++ b/blue_geo/.abcli/tests/generic.sh @@ -0,0 +1,8 @@ +#! /usr/bin/env bash + +function test_blue_geo_generic() { + local options=$1 + + abcli_eval ,$options \ + blue_geo build_README +} diff --git a/blue_geo/__init__.py b/blue_geo/__init__.py index bcb557d7..9f0da81d 100644 --- a/blue_geo/__init__.py +++ b/blue_geo/__init__.py @@ -4,7 +4,7 @@ DESCRIPTION = f"{ICON} AI for precise geospatial data analysis and visualization." -VERSION = "4.171.1" +VERSION = "4.172.1" REPO_NAME = "blue-geo" diff --git a/blue_geo/config.env b/blue_geo/config.env index 2136ac75..461b79d4 100644 --- a/blue_geo/config.env +++ b/blue_geo/config.env @@ -1,3 +1,5 @@ BLUE_GEO_UKRAINE_TIMEMAP_QGIS_TEMPLATE=ukraine-timemap-template-v11 -BLUE_GEO_FIRMS_AREA_QGIS_TEMPLATE=firms_area-template-v1 \ No newline at end of file +BLUE_GEO_FIRMS_AREA_QGIS_TEMPLATE=firms_area-template-v1 + +BLUE_GEO_TEST_DATACUBE_FIRMS_AREA=datacube-firms-area-world-MODIS_NRT-2024-07-20-1 \ No newline at end of file diff --git a/blue_geo/env.py b/blue_geo/env.py index 7c6ad06a..b9d72f74 100644 --- a/blue_geo/env.py +++ b/blue_geo/env.py @@ -19,3 +19,8 @@ QGIS_TEMPLATES = { "firms_area": BLUE_GEO_FIRMS_AREA_QGIS_TEMPLATE, } + +BLUE_GEO_TEST_DATACUBE_FIRMS_AREA = os.getenv( + "BLUE_GEO_TEST_DATACUBE_FIRMS_AREA", + "", +) diff --git a/blue_geo/tests/assets.py b/blue_geo/tests/assets.py index 230f59ab..c5b755a7 100644 --- a/blue_geo/tests/assets.py +++ b/blue_geo/tests/assets.py @@ -1,5 +1,6 @@ from blue_geo.catalog.generic import GenericDatacube, VoidDatacube from blue_geo.catalog.firms.area import FirmsAreaDatacube +from blue_geo import env datacubes = { @@ -14,5 +15,5 @@ "datacube-firms-area-void-void-void-void": VoidDatacube, "datacube-firms-area-world-void-2024-07-20-1": VoidDatacube, "datacube-firms-area-void-MODIS_NRT-2024-07-20-1": VoidDatacube, - "datacube-firms-area-world-MODIS_NRT-2024-07-20-1": FirmsAreaDatacube, + env.BLUE_GEO_TEST_DATACUBE_FIRMS_AREA: FirmsAreaDatacube, } diff --git a/blue_geo/tests/test_build_README.py b/blue_geo/tests/test_README.py similarity index 100% rename from blue_geo/tests/test_build_README.py rename to blue_geo/tests/test_README.py diff --git a/blue_geo/tests/test_env.py b/blue_geo/tests/test_env.py index 1d629455..c71bb67c 100644 --- a/blue_geo/tests/test_env.py +++ b/blue_geo/tests/test_env.py @@ -10,3 +10,4 @@ def test_blue_geo_env(): assert env.BLUE_GEO_UKRAINE_TIMEMAP_QGIS_TEMPLATE assert env.BLUE_GEO_FIRMS_AREA_QGIS_TEMPLATE assert env.FIRMS_MAP_KEY + assert env.BLUE_GEO_TEST_DATACUBE_FIRMS_AREA