generated from kamangir/blue-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from kamangir/watch-targets-refactors-2024-10-…
…07-33560 watch targets refactors
- Loading branch information
Showing
17 changed files
with
292 additions
and
126 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
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
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#! /usr/bin/env bash | ||
|
||
function test_blue_geo_watch_targets_list() { | ||
local options=$1 | ||
|
||
abcli_download - $BLUE_GEO_WATCH_TARGET_LIST | ||
|
||
abcli_assert \ | ||
$(blue_geo_watch_targets list \ | ||
--delim + \ | ||
--log 0) \ | ||
- non-empty | ||
[[ $? -ne 0 ]] && return 1 | ||
|
||
abcli_assert \ | ||
$(blue_geo_watch_targets list \ | ||
--catalog_name SkyFox \ | ||
--collection Venus \ | ||
--delim + \ | ||
--log 0) \ | ||
- non-empty | ||
} |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#! /usr/bin/env bash | ||
|
||
function test_blue_geo_watch_targets_save() { | ||
local options=$1 | ||
|
||
abcli_download - $BLUE_GEO_WATCH_TARGET_LIST | ||
|
||
local target_name | ||
for target_name in Leonardo all; do | ||
local object_name="test_blue_geo_watch_targets_save-$target_name-$(abcli_string_timestamp)" | ||
|
||
blue_geo_watch_targets save \ | ||
target=$target_name \ | ||
$object_name | ||
|
||
local object_path=$ABCLI_OBJECT_ROOT/$object_name | ||
[[ ! -f "$object_path/target/shape.geojson" ]] && | ||
return 1 | ||
|
||
abcli_hr | ||
done | ||
|
||
return 0 | ||
} |
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
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
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,77 +1,36 @@ | ||
import pytest | ||
from shapely.geometry import Polygon | ||
|
||
from blue_objects import file | ||
from blue_objects import file, objects | ||
|
||
from blue_geo.watch.targets.classes import Target, TargetList | ||
|
||
|
||
@pytest.fixture | ||
def target_list(): | ||
return TargetList(download=True) | ||
|
||
|
||
def test_target(target_list: TargetList): | ||
target = target_list.list_of_targets["elkhema"] | ||
|
||
assert target.one_liner | ||
from blue_geo.tests.test_target_list import target_list | ||
from blue_geo.watch.targets import TargetList, Target | ||
|
||
|
||
@pytest.mark.parametrize( | ||
["catalog_name", "collection", "expected_target"], | ||
[ | ||
["SkyFox", "Venus", "Leonardo"], | ||
["EarthSearch", "sentinel_2_l1c", "burning-man-2024"], | ||
], | ||
["target_name"], | ||
[["elkhema"]], | ||
) | ||
def test_target_list( | ||
catalog_name: str, | ||
collection: str, | ||
expected_target: str, | ||
def test_target( | ||
target_list: TargetList, | ||
target_name: str, | ||
): | ||
assert target_list.list_of_targets | ||
|
||
assert target_list.test() | ||
|
||
assert target_list.object_name | ||
target = target_list.list_of_targets[target_name] | ||
|
||
assert file.exists(target_list.filename()) | ||
|
||
list_of_targets = target_list.get_list( | ||
catalog_name=catalog_name, | ||
collection=collection, | ||
) | ||
assert isinstance(target, Target) | ||
|
||
assert expected_target in list_of_targets | ||
|
||
|
||
def test_targets_load(target_list: TargetList): | ||
assert target_list.list_of_targets | ||
assert target.one_liner | ||
|
||
for target in target_list.list_of_targets.values(): | ||
assert isinstance(target, Target) | ||
polygon = target.polygon | ||
assert isinstance(polygon, Polygon) | ||
|
||
for target in ["chilcotin-river-landslide", "elkhema"]: | ||
assert target in target_list.list_of_targets | ||
object_name = objects.unique_object() | ||
|
||
assert target.save(object_name) | ||
|
||
def test_targets_get( | ||
target_list: TargetList, | ||
): | ||
target = target_list.get("bellingcat-2024-09-27-nagorno-karabakh") | ||
assert target.query_args["datetime"] == "2024-05-01/2024-09-01" | ||
|
||
target = target_list.get( | ||
"bellingcat-2024-09-27-nagorno-karabakh-test", | ||
including_versions=False, | ||
assert file.exists( | ||
objects.path_of( | ||
filename="target/shape.geojson", | ||
object_name=object_name, | ||
) | ||
) | ||
assert not "count" in target.query_args | ||
|
||
target = target_list.get("bellingcat-2024-09-27-nagorno-karabakh-void") | ||
assert not "count" in target.query_args | ||
|
||
target = target_list.get("bellingcat-2024-09-27-nagorno-karabakh") | ||
assert target.query_args["count"] == 30 | ||
|
||
target = target_list.get("bellingcat-2024-09-27-nagorno-karabakh-test") | ||
assert target.query_args["count"] == 2 |
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 |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import pytest | ||
|
||
from blue_objects import file, objects | ||
from blue_geo.watch.targets.classes import Target, TargetList | ||
|
||
|
||
@pytest.fixture | ||
def target_list(): | ||
return TargetList(download=True) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
["catalog_name", "collection", "expected_target"], | ||
[ | ||
["SkyFox", "Venus", "Leonardo"], | ||
["EarthSearch", "sentinel_2_l1c", "burning-man-2024"], | ||
], | ||
) | ||
def test_target_list( | ||
catalog_name: str, | ||
collection: str, | ||
expected_target: str, | ||
target_list: TargetList, | ||
): | ||
assert target_list.list_of_targets | ||
|
||
assert target_list.test() | ||
|
||
assert target_list.object_name | ||
|
||
assert file.exists(target_list.filename()) | ||
|
||
list_of_targets = target_list.get_list( | ||
catalog_name=catalog_name, | ||
collection=collection, | ||
) | ||
|
||
assert expected_target in list_of_targets | ||
|
||
|
||
def test_target_list_load(target_list: TargetList): | ||
assert target_list.list_of_targets | ||
|
||
for target in target_list.list_of_targets.values(): | ||
assert isinstance(target, Target) | ||
|
||
for target in ["chilcotin-river-landslide", "elkhema"]: | ||
assert target in target_list.list_of_targets | ||
|
||
|
||
def test_target_list_get( | ||
target_list: TargetList, | ||
): | ||
target = target_list.get("bellingcat-2024-09-27-nagorno-karabakh") | ||
assert target.query_args["datetime"] == "2024-05-01/2024-09-01" | ||
|
||
target = target_list.get( | ||
"bellingcat-2024-09-27-nagorno-karabakh-test", | ||
including_versions=False, | ||
) | ||
assert not "count" in target.query_args | ||
|
||
target = target_list.get("bellingcat-2024-09-27-nagorno-karabakh-void") | ||
assert not "count" in target.query_args | ||
|
||
target = target_list.get("bellingcat-2024-09-27-nagorno-karabakh") | ||
assert target.query_args["count"] == 30 | ||
|
||
target = target_list.get("bellingcat-2024-09-27-nagorno-karabakh-test") | ||
assert target.query_args["count"] == 2 | ||
|
||
|
||
def test_target_list_save( | ||
target_list: TargetList, | ||
): | ||
object_name = objects.unique_object() | ||
|
||
assert target_list.save(object_name) | ||
|
||
assert file.exists( | ||
objects.path_of( | ||
filename="target/shape.geojson", | ||
object_name=object_name, | ||
) | ||
) |
Oops, something went wrong.