generated from linz/template-python-hello-world
-
Notifications
You must be signed in to change notification settings - Fork 3
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
* wip: optional inputs for downloading files * fix: download sidecars at same time as tiffs * fix: optional parameter default value * fix: formatting * fix: download sidecar files, ignore 404 * fix: appease pylint * fix: remove temporary sidecar test file * fix: handle local exception * fix: handle local exception better * fix: remove testing array * refactor: Use generic error for S3 & local file read Simplifies users of `read`. * fix: update translate_ascii script * docs: update for new functions * test: for fs functions * fix: formatting * test: fix list * fix: rename test file for pylint issue * fix: rename test file for pylint issue * test: minor changes * fix: formatting * fix: Enable importing `scripts.stac` * fix: Disable duplicate code test (#817) * fix: Disable duplicate code test It's not particularly useful for test code. * fix: Run a single pylint command for the repo Ensures that any checks which deal with multiple files (such as duplicate code) can detect these. * fix: disable pylint duplicate check at the individual test level * fix: remove duplicate check --------- Co-authored-by: Victor Engmark <[email protected]> Co-authored-by: Paul Fouquet <[email protected]>
- Loading branch information
1 parent
cde875d
commit 16b5b04
Showing
9 changed files
with
115 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import json | ||
|
||
from boto3 import resource | ||
from moto import mock_s3 | ||
from moto.s3.responses import DEFAULT_REGION_NAME | ||
from pytest import CaptureFixture, raises | ||
|
||
from scripts.files.fs import NoSuchFileError, read, write_all, write_sidecars | ||
|
||
|
||
def test_read_key_not_found_local() -> None: | ||
with raises(NoSuchFileError): | ||
read("test_dir/test.file") | ||
|
||
|
||
@mock_s3 # type: ignore | ||
def test_read_key_not_found_s3(capsys: CaptureFixture[str]) -> None: | ||
s3 = resource("s3", region_name=DEFAULT_REGION_NAME) | ||
s3.create_bucket(Bucket="testbucket") | ||
|
||
with raises(NoSuchFileError): | ||
read("s3://testbucket/test.file") | ||
|
||
logs = json.loads(capsys.readouterr().out) | ||
assert logs["msg"] == "s3_key_not_found" | ||
|
||
|
||
def test_write_all_file_not_found_local() -> None: | ||
with raises(NoSuchFileError): | ||
write_all(["/test.prj"], "/tmp") | ||
|
||
|
||
def test_write_sidecars_file_not_found_local(capsys: CaptureFixture[str]) -> None: | ||
write_sidecars(["/test.prj"], "/tmp") | ||
|
||
logs = json.loads(capsys.readouterr().out.strip()) | ||
assert logs["msg"] == "No sidecar file found; skipping" | ||
|
||
|
||
@mock_s3 # type: ignore | ||
def test_write_all_key_not_found_s3() -> None: | ||
s3 = resource("s3", region_name=DEFAULT_REGION_NAME) | ||
s3.create_bucket(Bucket="testbucket") | ||
|
||
with raises(NoSuchFileError): | ||
write_all(["s3://testbucket/test.tif"], "/tmp") | ||
|
||
|
||
@mock_s3 # type: ignore | ||
def test_write_sidecars_key_not_found_s3(capsys: CaptureFixture[str]) -> None: | ||
s3 = resource("s3", region_name=DEFAULT_REGION_NAME) | ||
s3.create_bucket(Bucket="testbucket") | ||
|
||
write_sidecars(["s3://testbucket/test.prj"], "/tmp") | ||
|
||
# capsys.readouterr().out json string format is not valid which implies | ||
# we can't parse it to find the actual `msg` | ||
assert "No sidecar file found; skipping" in capsys.readouterr().out |
Empty file.
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
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