Skip to content

Commit

Permalink
bashtest refactors - kamangir/bolt#746
Browse files Browse the repository at this point in the history
  • Loading branch information
kamangir committed Jul 30, 2024
1 parent 91b37fa commit 8268e2c
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 19 deletions.
9 changes: 5 additions & 4 deletions blue_geo/.abcli/catalog/browse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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<catalog>$ABCUL[<args>]" \
"browse <catalog>."
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}"
}
4 changes: 4 additions & 0 deletions blue_geo/.abcli/catalog/generic/query.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
59 changes: 59 additions & 0 deletions blue_geo/.abcli/tests/catalog.sh
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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
}
6 changes: 0 additions & 6 deletions blue_geo/.abcli/tests/datacube_catalog.sh

This file was deleted.

15 changes: 12 additions & 3 deletions blue_geo/.abcli/tests/datacube_get.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
8 changes: 8 additions & 0 deletions blue_geo/.abcli/tests/generic.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#! /usr/bin/env bash

function test_blue_geo_generic() {
local options=$1

abcli_eval ,$options \
blue_geo build_README
}
2 changes: 1 addition & 1 deletion blue_geo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 3 additions & 1 deletion blue_geo/config.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
BLUE_GEO_UKRAINE_TIMEMAP_QGIS_TEMPLATE=ukraine-timemap-template-v11

BLUE_GEO_FIRMS_AREA_QGIS_TEMPLATE=firms_area-template-v1
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
5 changes: 5 additions & 0 deletions blue_geo/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
"",
)
3 changes: 2 additions & 1 deletion blue_geo/tests/assets.py
Original file line number Diff line number Diff line change
@@ -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 = {
Expand All @@ -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,
}
File renamed without changes.
1 change: 1 addition & 0 deletions blue_geo/tests/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 8268e2c

Please sign in to comment.