-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* bump default pypgstac version in bootstrapper * fix regression introduced by #19 * convert StacCollection object to list of Dict to comply with pypgstac expectations * format * add unit test that verifies the call to pypgstac.load.Loader.load_collections to avoid future regressions * format * clean up conftest StacCollection generator, make use of it in new test * remove unused import
- Loading branch information
Showing
4 changed files
with
42 additions
and
17 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,35 @@ | ||
from unittest.mock import Mock, patch | ||
import pytest | ||
from pypgstac.load import Methods | ||
from src.utils import DbCreds | ||
import src.collection as collection | ||
import os | ||
|
||
|
||
@pytest.fixture() | ||
def loader(): | ||
with patch("src.collection.Loader", autospec=True) as m: | ||
yield m | ||
|
||
|
||
@pytest.fixture() | ||
def pgstacdb(): | ||
with patch("src.collection.PgstacDB", autospec=True) as m: | ||
m.return_value.__enter__.return_value = Mock() | ||
yield m | ||
|
||
|
||
def test_load_collections(stac_collection, loader, pgstacdb): | ||
with patch( | ||
"src.collection.get_db_credentials", | ||
return_value=DbCreds( | ||
username="", password="", host="", port=1, dbname="", engine="" | ||
), | ||
): | ||
os.environ["DB_SECRET_ARN"] = "" | ||
collection.ingest(stac_collection) | ||
|
||
loader.return_value.load_collections.assert_called_once_with( | ||
file=[stac_collection.to_dict()], | ||
insert_mode=Methods.upsert, | ||
) |