diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 007addc..21d3eb1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,7 +20,7 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: 'v0.4.2' + rev: 'v0.4.10' hooks: - id: ruff args: [ "--fix" ] diff --git a/CHANGELOG.md b/CHANGELOG.md index ac15518..fa6b8be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [issue #127](https://github.com/nasa/batchee/issues/127): Group dependabot updates into fewer PRs - [issue #129](https://github.com/nasa/batchee/issues/129): Add autoupdate schedule for pre-commit ### Changed +- [issue #128](https://github.com/nasa/batchee/issues/128): Increase continuous integration/unit test coverage ### Deprecated ### Removed ### Fixed diff --git a/batcher/harmony/service_adapter.py b/batcher/harmony/service_adapter.py index 8723d57..b35ac51 100644 --- a/batcher/harmony/service_adapter.py +++ b/batcher/harmony/service_adapter.py @@ -125,7 +125,7 @@ def process_catalog(self, catalog: pystac.Catalog) -> list[pystac.Catalog]: _get_output_date_range([item]), ) output_item.add_asset( - f"data_{idx}", + "data", Asset( _get_item_url(item), title=_get_item_url(item), diff --git a/batcher/tempo_filename_parser.py b/batcher/tempo_filename_parser.py index dc7a346..ceb7c8a 100644 --- a/batcher/tempo_filename_parser.py +++ b/batcher/tempo_filename_parser.py @@ -28,7 +28,6 @@ import logging import re from argparse import ArgumentParser -from pathlib import Path default_logger = logging.getLogger(__name__) @@ -99,7 +98,7 @@ def main() -> list[list[str]]: if args.verbose: logging.basicConfig(level=logging.DEBUG) - input_filenames = [str(Path(f).resolve()) for f in args.file_names] + input_filenames = args.file_names batch_indices = get_batch_indices(input_filenames) unique_category_indices: list[int] = sorted(set(batch_indices), key=batch_indices.index) diff --git a/poetry.lock b/poetry.lock index b50d47d..3c27217 100644 --- a/poetry.lock +++ b/poetry.lock @@ -48,17 +48,17 @@ uvloop = ["uvloop (>=0.15.2)"] [[package]] name = "boto3" -version = "1.34.95" +version = "1.34.131" description = "The AWS SDK for Python" optional = false python-versions = ">=3.8" files = [ - {file = "boto3-1.34.95-py3-none-any.whl", hash = "sha256:e836b71d79671270fccac0a4d4c8ec239a6b82ea47c399b64675aa597d0ee63b"}, - {file = "boto3-1.34.95.tar.gz", hash = "sha256:decf52f8d5d8a1b10c9ff2a0e96ee207ed79e33d2e53fdf0880a5cbef70785e0"}, + {file = "boto3-1.34.131-py3-none-any.whl", hash = "sha256:05e388cb937e82be70bfd7eb0c84cf8011ff35cf582a593873ac21675268683b"}, + {file = "boto3-1.34.131.tar.gz", hash = "sha256:dab8f72a6c4e62b4fd70da09e08a6b2a65ea2115b27dd63737142005776ef216"}, ] [package.dependencies] -botocore = ">=1.34.95,<1.35.0" +botocore = ">=1.34.131,<1.35.0" jmespath = ">=0.7.1,<2.0.0" s3transfer = ">=0.10.0,<0.11.0" @@ -67,13 +67,13 @@ crt = ["botocore[crt] (>=1.21.0,<2.0a0)"] [[package]] name = "botocore" -version = "1.34.95" +version = "1.34.131" description = "Low-level, data-driven core of boto 3." optional = false python-versions = ">=3.8" files = [ - {file = "botocore-1.34.95-py3-none-any.whl", hash = "sha256:ead5823e0dd6751ece5498cb979fd9abf190e691c8833bcac6876fd6ca261fa7"}, - {file = "botocore-1.34.95.tar.gz", hash = "sha256:6bd76a2eadb42b91fa3528392e981ad5b4dfdee3968fa5b904278acf6cbf15ff"}, + {file = "botocore-1.34.131-py3-none-any.whl", hash = "sha256:13b011d7b206ce00727dcee26548fa3b550db9046d5a0e90ac25a6e6c8fde6ef"}, + {file = "botocore-1.34.131.tar.gz", hash = "sha256:502ddafe1d627fcf1e4c007c86454e5dd011dba7c58bd8e8a5368a79f3e387dc"}, ] [package.dependencies] @@ -82,17 +82,17 @@ python-dateutil = ">=2.1,<3.0.0" urllib3 = {version = ">=1.25.4,<2.2.0 || >2.2.0,<3", markers = "python_version >= \"3.10\""} [package.extras] -crt = ["awscrt (==0.20.9)"] +crt = ["awscrt (==0.20.11)"] [[package]] name = "certifi" -version = "2024.2.2" +version = "2024.6.2" description = "Python package for providing Mozilla's CA Bundle." optional = false python-versions = ">=3.6" files = [ - {file = "certifi-2024.2.2-py3-none-any.whl", hash = "sha256:dc383c07b76109f368f6106eee2b593b04a011ea4d55f652c6ca24a754d1cdd1"}, - {file = "certifi-2024.2.2.tar.gz", hash = "sha256:0569859f95fc761b18b45ef421b1290a0f65f147e92a1e5eb3e635f9a5e4e66f"}, + {file = "certifi-2024.6.2-py3-none-any.whl", hash = "sha256:ddc6c8ce995e6987e7faf5e3f1b02b302836a0e5d98ece18392cb1a36c72ad56"}, + {file = "certifi-2024.6.2.tar.gz", hash = "sha256:3cd43f1c6fa7dedc5899d69d3ad0398fd018ad1a17fba83ddaf78aa46c747516"}, ] [[package]] @@ -285,63 +285,63 @@ files = [ [[package]] name = "coverage" -version = "7.5.3" +version = "7.5.4" description = "Code coverage measurement for Python" optional = false python-versions = ">=3.8" files = [ - {file = "coverage-7.5.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:a6519d917abb15e12380406d721e37613e2a67d166f9fb7e5a8ce0375744cd45"}, - {file = "coverage-7.5.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:aea7da970f1feccf48be7335f8b2ca64baf9b589d79e05b9397a06696ce1a1ec"}, - {file = "coverage-7.5.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:923b7b1c717bd0f0f92d862d1ff51d9b2b55dbbd133e05680204465f454bb286"}, - {file = "coverage-7.5.3-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:62bda40da1e68898186f274f832ef3e759ce929da9a9fd9fcf265956de269dbc"}, - {file = "coverage-7.5.3-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d8b7339180d00de83e930358223c617cc343dd08e1aa5ec7b06c3a121aec4e1d"}, - {file = "coverage-7.5.3-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:25a5caf742c6195e08002d3b6c2dd6947e50efc5fc2c2205f61ecb47592d2d83"}, - {file = "coverage-7.5.3-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:05ac5f60faa0c704c0f7e6a5cbfd6f02101ed05e0aee4d2822637a9e672c998d"}, - {file = "coverage-7.5.3-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:239a4e75e09c2b12ea478d28815acf83334d32e722e7433471fbf641c606344c"}, - {file = "coverage-7.5.3-cp310-cp310-win32.whl", hash = "sha256:a5812840d1d00eafae6585aba38021f90a705a25b8216ec7f66aebe5b619fb84"}, - {file = "coverage-7.5.3-cp310-cp310-win_amd64.whl", hash = "sha256:33ca90a0eb29225f195e30684ba4a6db05dbef03c2ccd50b9077714c48153cac"}, - {file = "coverage-7.5.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:f81bc26d609bf0fbc622c7122ba6307993c83c795d2d6f6f6fd8c000a770d974"}, - {file = "coverage-7.5.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:7cec2af81f9e7569280822be68bd57e51b86d42e59ea30d10ebdbb22d2cb7232"}, - {file = "coverage-7.5.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:55f689f846661e3f26efa535071775d0483388a1ccfab899df72924805e9e7cd"}, - {file = "coverage-7.5.3-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:50084d3516aa263791198913a17354bd1dc627d3c1639209640b9cac3fef5807"}, - {file = "coverage-7.5.3-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:341dd8f61c26337c37988345ca5c8ccabeff33093a26953a1ac72e7d0103c4fb"}, - {file = "coverage-7.5.3-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:ab0b028165eea880af12f66086694768f2c3139b2c31ad5e032c8edbafca6ffc"}, - {file = "coverage-7.5.3-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:5bc5a8c87714b0c67cfeb4c7caa82b2d71e8864d1a46aa990b5588fa953673b8"}, - {file = "coverage-7.5.3-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:38a3b98dae8a7c9057bd91fbf3415c05e700a5114c5f1b5b0ea5f8f429ba6614"}, - {file = "coverage-7.5.3-cp311-cp311-win32.whl", hash = "sha256:fcf7d1d6f5da887ca04302db8e0e0cf56ce9a5e05f202720e49b3e8157ddb9a9"}, - {file = "coverage-7.5.3-cp311-cp311-win_amd64.whl", hash = "sha256:8c836309931839cca658a78a888dab9676b5c988d0dd34ca247f5f3e679f4e7a"}, - {file = "coverage-7.5.3-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:296a7d9bbc598e8744c00f7a6cecf1da9b30ae9ad51c566291ff1314e6cbbed8"}, - {file = "coverage-7.5.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:34d6d21d8795a97b14d503dcaf74226ae51eb1f2bd41015d3ef332a24d0a17b3"}, - {file = "coverage-7.5.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8e317953bb4c074c06c798a11dbdd2cf9979dbcaa8ccc0fa4701d80042d4ebf1"}, - {file = "coverage-7.5.3-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:705f3d7c2b098c40f5b81790a5fedb274113373d4d1a69e65f8b68b0cc26f6db"}, - {file = "coverage-7.5.3-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b1196e13c45e327d6cd0b6e471530a1882f1017eb83c6229fc613cd1a11b53cd"}, - {file = "coverage-7.5.3-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:015eddc5ccd5364dcb902eaecf9515636806fa1e0d5bef5769d06d0f31b54523"}, - {file = "coverage-7.5.3-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:fd27d8b49e574e50caa65196d908f80e4dff64d7e592d0c59788b45aad7e8b35"}, - {file = "coverage-7.5.3-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:33fc65740267222fc02975c061eb7167185fef4cc8f2770267ee8bf7d6a42f84"}, - {file = "coverage-7.5.3-cp312-cp312-win32.whl", hash = "sha256:7b2a19e13dfb5c8e145c7a6ea959485ee8e2204699903c88c7d25283584bfc08"}, - {file = "coverage-7.5.3-cp312-cp312-win_amd64.whl", hash = "sha256:0bbddc54bbacfc09b3edaec644d4ac90c08ee8ed4844b0f86227dcda2d428fcb"}, - {file = "coverage-7.5.3-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:f78300789a708ac1f17e134593f577407d52d0417305435b134805c4fb135adb"}, - {file = "coverage-7.5.3-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:b368e1aee1b9b75757942d44d7598dcd22a9dbb126affcbba82d15917f0cc155"}, - {file = "coverage-7.5.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f836c174c3a7f639bded48ec913f348c4761cbf49de4a20a956d3431a7c9cb24"}, - {file = "coverage-7.5.3-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:244f509f126dc71369393ce5fea17c0592c40ee44e607b6d855e9c4ac57aac98"}, - {file = "coverage-7.5.3-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c4c2872b3c91f9baa836147ca33650dc5c172e9273c808c3c3199c75490e709d"}, - {file = "coverage-7.5.3-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:dd4b3355b01273a56b20c219e74e7549e14370b31a4ffe42706a8cda91f19f6d"}, - {file = "coverage-7.5.3-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:f542287b1489c7a860d43a7d8883e27ca62ab84ca53c965d11dac1d3a1fab7ce"}, - {file = "coverage-7.5.3-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:75e3f4e86804023e991096b29e147e635f5e2568f77883a1e6eed74512659ab0"}, - {file = "coverage-7.5.3-cp38-cp38-win32.whl", hash = "sha256:c59d2ad092dc0551d9f79d9d44d005c945ba95832a6798f98f9216ede3d5f485"}, - {file = "coverage-7.5.3-cp38-cp38-win_amd64.whl", hash = "sha256:fa21a04112c59ad54f69d80e376f7f9d0f5f9123ab87ecd18fbb9ec3a2beed56"}, - {file = "coverage-7.5.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:f5102a92855d518b0996eb197772f5ac2a527c0ec617124ad5242a3af5e25f85"}, - {file = "coverage-7.5.3-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:d1da0a2e3b37b745a2b2a678a4c796462cf753aebf94edcc87dcc6b8641eae31"}, - {file = "coverage-7.5.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8383a6c8cefba1b7cecc0149415046b6fc38836295bc4c84e820872eb5478b3d"}, - {file = "coverage-7.5.3-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9aad68c3f2566dfae84bf46295a79e79d904e1c21ccfc66de88cd446f8686341"}, - {file = "coverage-7.5.3-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2e079c9ec772fedbade9d7ebc36202a1d9ef7291bc9b3a024ca395c4d52853d7"}, - {file = "coverage-7.5.3-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:bde997cac85fcac227b27d4fb2c7608a2c5f6558469b0eb704c5726ae49e1c52"}, - {file = "coverage-7.5.3-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:990fb20b32990b2ce2c5f974c3e738c9358b2735bc05075d50a6f36721b8f303"}, - {file = "coverage-7.5.3-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:3d5a67f0da401e105753d474369ab034c7bae51a4c31c77d94030d59e41df5bd"}, - {file = "coverage-7.5.3-cp39-cp39-win32.whl", hash = "sha256:e08c470c2eb01977d221fd87495b44867a56d4d594f43739a8028f8646a51e0d"}, - {file = "coverage-7.5.3-cp39-cp39-win_amd64.whl", hash = "sha256:1d2a830ade66d3563bb61d1e3c77c8def97b30ed91e166c67d0632c018f380f0"}, - {file = "coverage-7.5.3-pp38.pp39.pp310-none-any.whl", hash = "sha256:3538d8fb1ee9bdd2e2692b3b18c22bb1c19ffbefd06880f5ac496e42d7bb3884"}, - {file = "coverage-7.5.3.tar.gz", hash = "sha256:04aefca5190d1dc7a53a4c1a5a7f8568811306d7a8ee231c42fb69215571944f"}, + {file = "coverage-7.5.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:6cfb5a4f556bb51aba274588200a46e4dd6b505fb1a5f8c5ae408222eb416f99"}, + {file = "coverage-7.5.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:2174e7c23e0a454ffe12267a10732c273243b4f2d50d07544a91198f05c48f47"}, + {file = "coverage-7.5.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2214ee920787d85db1b6a0bd9da5f8503ccc8fcd5814d90796c2f2493a2f4d2e"}, + {file = "coverage-7.5.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1137f46adb28e3813dec8c01fefadcb8c614f33576f672962e323b5128d9a68d"}, + {file = "coverage-7.5.4-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b385d49609f8e9efc885790a5a0e89f2e3ae042cdf12958b6034cc442de428d3"}, + {file = "coverage-7.5.4-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:b4a474f799456e0eb46d78ab07303286a84a3140e9700b9e154cfebc8f527016"}, + {file = "coverage-7.5.4-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:5cd64adedf3be66f8ccee418473c2916492d53cbafbfcff851cbec5a8454b136"}, + {file = "coverage-7.5.4-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:e564c2cf45d2f44a9da56f4e3a26b2236504a496eb4cb0ca7221cd4cc7a9aca9"}, + {file = "coverage-7.5.4-cp310-cp310-win32.whl", hash = "sha256:7076b4b3a5f6d2b5d7f1185fde25b1e54eb66e647a1dfef0e2c2bfaf9b4c88c8"}, + {file = "coverage-7.5.4-cp310-cp310-win_amd64.whl", hash = "sha256:018a12985185038a5b2bcafab04ab833a9a0f2c59995b3cec07e10074c78635f"}, + {file = "coverage-7.5.4-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:db14f552ac38f10758ad14dd7b983dbab424e731588d300c7db25b6f89e335b5"}, + {file = "coverage-7.5.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:3257fdd8e574805f27bb5342b77bc65578e98cbc004a92232106344053f319ba"}, + {file = "coverage-7.5.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3a6612c99081d8d6134005b1354191e103ec9705d7ba2754e848211ac8cacc6b"}, + {file = "coverage-7.5.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d45d3cbd94159c468b9b8c5a556e3f6b81a8d1af2a92b77320e887c3e7a5d080"}, + {file = "coverage-7.5.4-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ed550e7442f278af76d9d65af48069f1fb84c9f745ae249c1a183c1e9d1b025c"}, + {file = "coverage-7.5.4-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:7a892be37ca35eb5019ec85402c3371b0f7cda5ab5056023a7f13da0961e60da"}, + {file = "coverage-7.5.4-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:8192794d120167e2a64721d88dbd688584675e86e15d0569599257566dec9bf0"}, + {file = "coverage-7.5.4-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:820bc841faa502e727a48311948e0461132a9c8baa42f6b2b84a29ced24cc078"}, + {file = "coverage-7.5.4-cp311-cp311-win32.whl", hash = "sha256:6aae5cce399a0f065da65c7bb1e8abd5c7a3043da9dceb429ebe1b289bc07806"}, + {file = "coverage-7.5.4-cp311-cp311-win_amd64.whl", hash = "sha256:d2e344d6adc8ef81c5a233d3a57b3c7d5181f40e79e05e1c143da143ccb6377d"}, + {file = "coverage-7.5.4-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:54317c2b806354cbb2dc7ac27e2b93f97096912cc16b18289c5d4e44fc663233"}, + {file = "coverage-7.5.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:042183de01f8b6d531e10c197f7f0315a61e8d805ab29c5f7b51a01d62782747"}, + {file = "coverage-7.5.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a6bb74ed465d5fb204b2ec41d79bcd28afccf817de721e8a807d5141c3426638"}, + {file = "coverage-7.5.4-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b3d45ff86efb129c599a3b287ae2e44c1e281ae0f9a9bad0edc202179bcc3a2e"}, + {file = "coverage-7.5.4-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5013ed890dc917cef2c9f765c4c6a8ae9df983cd60dbb635df8ed9f4ebc9f555"}, + {file = "coverage-7.5.4-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:1014fbf665fef86cdfd6cb5b7371496ce35e4d2a00cda501cf9f5b9e6fced69f"}, + {file = "coverage-7.5.4-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:3684bc2ff328f935981847082ba4fdc950d58906a40eafa93510d1b54c08a66c"}, + {file = "coverage-7.5.4-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:581ea96f92bf71a5ec0974001f900db495488434a6928a2ca7f01eee20c23805"}, + {file = "coverage-7.5.4-cp312-cp312-win32.whl", hash = "sha256:73ca8fbc5bc622e54627314c1a6f1dfdd8db69788f3443e752c215f29fa87a0b"}, + {file = "coverage-7.5.4-cp312-cp312-win_amd64.whl", hash = "sha256:cef4649ec906ea7ea5e9e796e68b987f83fa9a718514fe147f538cfeda76d7a7"}, + {file = "coverage-7.5.4-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:cdd31315fc20868c194130de9ee6bfd99755cc9565edff98ecc12585b90be882"}, + {file = "coverage-7.5.4-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:02ff6e898197cc1e9fa375581382b72498eb2e6d5fc0b53f03e496cfee3fac6d"}, + {file = "coverage-7.5.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d05c16cf4b4c2fc880cb12ba4c9b526e9e5d5bb1d81313d4d732a5b9fe2b9d53"}, + {file = "coverage-7.5.4-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c5986ee7ea0795a4095ac4d113cbb3448601efca7f158ec7f7087a6c705304e4"}, + {file = "coverage-7.5.4-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5df54843b88901fdc2f598ac06737f03d71168fd1175728054c8f5a2739ac3e4"}, + {file = "coverage-7.5.4-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:ab73b35e8d109bffbda9a3e91c64e29fe26e03e49addf5b43d85fc426dde11f9"}, + {file = "coverage-7.5.4-cp38-cp38-musllinux_1_2_i686.whl", hash = "sha256:aea072a941b033813f5e4814541fc265a5c12ed9720daef11ca516aeacd3bd7f"}, + {file = "coverage-7.5.4-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:16852febd96acd953b0d55fc842ce2dac1710f26729b31c80b940b9afcd9896f"}, + {file = "coverage-7.5.4-cp38-cp38-win32.whl", hash = "sha256:8f894208794b164e6bd4bba61fc98bf6b06be4d390cf2daacfa6eca0a6d2bb4f"}, + {file = "coverage-7.5.4-cp38-cp38-win_amd64.whl", hash = "sha256:e2afe743289273209c992075a5a4913e8d007d569a406ffed0bd080ea02b0633"}, + {file = "coverage-7.5.4-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:b95c3a8cb0463ba9f77383d0fa8c9194cf91f64445a63fc26fb2327e1e1eb088"}, + {file = "coverage-7.5.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:3d7564cc09dd91b5a6001754a5b3c6ecc4aba6323baf33a12bd751036c998be4"}, + {file = "coverage-7.5.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:44da56a2589b684813f86d07597fdf8a9c6ce77f58976727329272f5a01f99f7"}, + {file = "coverage-7.5.4-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e16f3d6b491c48c5ae726308e6ab1e18ee830b4cdd6913f2d7f77354b33f91c8"}, + {file = "coverage-7.5.4-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dbc5958cb471e5a5af41b0ddaea96a37e74ed289535e8deca404811f6cb0bc3d"}, + {file = "coverage-7.5.4-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:a04e990a2a41740b02d6182b498ee9796cf60eefe40cf859b016650147908029"}, + {file = "coverage-7.5.4-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:ddbd2f9713a79e8e7242d7c51f1929611e991d855f414ca9996c20e44a895f7c"}, + {file = "coverage-7.5.4-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:b1ccf5e728ccf83acd313c89f07c22d70d6c375a9c6f339233dcf792094bcbf7"}, + {file = "coverage-7.5.4-cp39-cp39-win32.whl", hash = "sha256:56b4eafa21c6c175b3ede004ca12c653a88b6f922494b023aeb1e836df953ace"}, + {file = "coverage-7.5.4-cp39-cp39-win_amd64.whl", hash = "sha256:65e528e2e921ba8fd67d9055e6b9f9e34b21ebd6768ae1c1723f4ea6ace1234d"}, + {file = "coverage-7.5.4-pp38.pp39.pp310-none-any.whl", hash = "sha256:79b356f3dd5b26f3ad23b35c75dbdaf1f9e2450b6bcefc6d0825ea0aa3f86ca5"}, + {file = "coverage-7.5.4.tar.gz", hash = "sha256:a44963520b069e12789d0faea4e9fdb1e410cdc4aab89d94f7f55cbb7fef0353"}, ] [package.dependencies] @@ -491,13 +491,13 @@ files = [ [[package]] name = "packaging" -version = "24.0" +version = "24.1" description = "Core utilities for Python packages" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "packaging-24.0-py3-none-any.whl", hash = "sha256:2ddfb553fdf02fb784c234c7ba6ccc288296ceabec964ad2eae3777778130bc5"}, - {file = "packaging-24.0.tar.gz", hash = "sha256:eb82c5e3e56209074766e6885bb04b8c38a0c015d0a30036ebe7ece34c9989e9"}, + {file = "packaging-24.1-py3-none-any.whl", hash = "sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124"}, + {file = "packaging-24.1.tar.gz", hash = "sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002"}, ] [[package]] @@ -513,13 +513,13 @@ files = [ [[package]] name = "platformdirs" -version = "4.2.1" +version = "4.2.2" description = "A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`." optional = false python-versions = ">=3.8" files = [ - {file = "platformdirs-4.2.1-py3-none-any.whl", hash = "sha256:17d5a1161b3fd67b390023cb2d3b026bbd40abde6fdb052dfbd3a29c3ba22ee1"}, - {file = "platformdirs-4.2.1.tar.gz", hash = "sha256:031cd18d4ec63ec53e82dceaac0417d218a6863f7745dfcc9efe7793b7039bdf"}, + {file = "platformdirs-4.2.2-py3-none-any.whl", hash = "sha256:2d7a1657e36a80ea911db832a8a6ece5ee53d8de21edd5cc5879af6530b1bfee"}, + {file = "platformdirs-4.2.2.tar.gz", hash = "sha256:38b7b51f512eed9e84a22788b4bce1de17c0adb134d6becb09836e37d8654cd3"}, ] [package.extras] @@ -598,13 +598,13 @@ validation = ["jsonschema (==3.2.0)"] [[package]] name = "pytest" -version = "8.2.1" +version = "8.2.2" description = "pytest: simple powerful testing with Python" optional = false python-versions = ">=3.8" files = [ - {file = "pytest-8.2.1-py3-none-any.whl", hash = "sha256:faccc5d332b8c3719f40283d0d44aa5cf101cec36f88cde9ed8f2bc0538612b1"}, - {file = "pytest-8.2.1.tar.gz", hash = "sha256:5046e5b46d8e4cac199c373041f26be56fdb81eb4e67dc11d4e10811fc3408fd"}, + {file = "pytest-8.2.2-py3-none-any.whl", hash = "sha256:c434598117762e2bd304e526244f67bf66bbd7b5d6cf22138be51ff661980343"}, + {file = "pytest-8.2.2.tar.gz", hash = "sha256:de4bb8104e201939ccdc688b27a89a7be2079b22e2bd2b07f806b6ba71117977"}, ] [package.dependencies] @@ -663,13 +663,13 @@ files = [ [[package]] name = "requests" -version = "2.32.2" +version = "2.32.3" description = "Python HTTP for Humans." optional = false python-versions = ">=3.8" files = [ - {file = "requests-2.32.2-py3-none-any.whl", hash = "sha256:fc06670dd0ed212426dfeb94fc1b983d917c4f9847c863f313c9dfaaffb7c23c"}, - {file = "requests-2.32.2.tar.gz", hash = "sha256:dd951ff5ecf3e3b3aa26b40703ba77495dab41da839ae72ef3c8e5d8e2433289"}, + {file = "requests-2.32.3-py3-none-any.whl", hash = "sha256:70761cfe03c773ceb22aa2f671b4757976145175cdfca038c02654d061d6dcc6"}, + {file = "requests-2.32.3.tar.gz", hash = "sha256:55365417734eb18255590a9ff9eb97e9e1da868d4ccd6402399eaf68af20a760"}, ] [package.dependencies] @@ -684,28 +684,28 @@ use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] [[package]] name = "ruff" -version = "0.4.7" +version = "0.4.10" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.4.7-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:e089371c67892a73b6bb1525608e89a2aca1b77b5440acf7a71dda5dac958f9e"}, - {file = "ruff-0.4.7-py3-none-macosx_11_0_arm64.whl", hash = "sha256:10f973d521d910e5f9c72ab27e409e839089f955be8a4c8826601a6323a89753"}, - {file = "ruff-0.4.7-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:59c3d110970001dfa494bcd95478e62286c751126dfb15c3c46e7915fc49694f"}, - {file = "ruff-0.4.7-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:fa9773c6c00f4958f73b317bc0fd125295110c3776089f6ef318f4b775f0abe4"}, - {file = "ruff-0.4.7-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:07fc80bbb61e42b3b23b10fda6a2a0f5a067f810180a3760c5ef1b456c21b9db"}, - {file = "ruff-0.4.7-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:fa4dafe3fe66d90e2e2b63fa1591dd6e3f090ca2128daa0be33db894e6c18648"}, - {file = "ruff-0.4.7-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a7c0083febdec17571455903b184a10026603a1de078428ba155e7ce9358c5f6"}, - {file = "ruff-0.4.7-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:ad1b20e66a44057c326168437d680a2166c177c939346b19c0d6b08a62a37589"}, - {file = "ruff-0.4.7-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cbf5d818553add7511c38b05532d94a407f499d1a76ebb0cad0374e32bc67202"}, - {file = "ruff-0.4.7-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:50e9651578b629baec3d1513b2534de0ac7ed7753e1382272b8d609997e27e83"}, - {file = "ruff-0.4.7-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:8874a9df7766cb956b218a0a239e0a5d23d9e843e4da1e113ae1d27ee420877a"}, - {file = "ruff-0.4.7-py3-none-musllinux_1_2_i686.whl", hash = "sha256:b9de9a6e49f7d529decd09381c0860c3f82fa0b0ea00ea78409b785d2308a567"}, - {file = "ruff-0.4.7-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:13a1768b0691619822ae6d446132dbdfd568b700ecd3652b20d4e8bc1e498f78"}, - {file = "ruff-0.4.7-py3-none-win32.whl", hash = "sha256:769e5a51df61e07e887b81e6f039e7ed3573316ab7dd9f635c5afaa310e4030e"}, - {file = "ruff-0.4.7-py3-none-win_amd64.whl", hash = "sha256:9e3ab684ad403a9ed1226894c32c3ab9c2e0718440f6f50c7c5829932bc9e054"}, - {file = "ruff-0.4.7-py3-none-win_arm64.whl", hash = "sha256:10f2204b9a613988e3484194c2c9e96a22079206b22b787605c255f130db5ed7"}, - {file = "ruff-0.4.7.tar.gz", hash = "sha256:2331d2b051dc77a289a653fcc6a42cce357087c5975738157cd966590b18b5e1"}, + {file = "ruff-0.4.10-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:5c2c4d0859305ac5a16310eec40e4e9a9dec5dcdfbe92697acd99624e8638dac"}, + {file = "ruff-0.4.10-py3-none-macosx_11_0_arm64.whl", hash = "sha256:a79489607d1495685cdd911a323a35871abfb7a95d4f98fc6f85e799227ac46e"}, + {file = "ruff-0.4.10-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b1dd1681dfa90a41b8376a61af05cc4dc5ff32c8f14f5fe20dba9ff5deb80cd6"}, + {file = "ruff-0.4.10-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:c75c53bb79d71310dc79fb69eb4902fba804a81f374bc86a9b117a8d077a1784"}, + {file = "ruff-0.4.10-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:18238c80ee3d9100d3535d8eb15a59c4a0753b45cc55f8bf38f38d6a597b9739"}, + {file = "ruff-0.4.10-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:d8f71885bce242da344989cae08e263de29752f094233f932d4f5cfb4ef36a81"}, + {file = "ruff-0.4.10-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:330421543bd3222cdfec481e8ff3460e8702ed1e58b494cf9d9e4bf90db52b9d"}, + {file = "ruff-0.4.10-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9e9b6fb3a37b772628415b00c4fc892f97954275394ed611056a4b8a2631365e"}, + {file = "ruff-0.4.10-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0f54c481b39a762d48f64d97351048e842861c6662d63ec599f67d515cb417f6"}, + {file = "ruff-0.4.10-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:67fe086b433b965c22de0b4259ddfe6fa541c95bf418499bedb9ad5fb8d1c631"}, + {file = "ruff-0.4.10-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:acfaaab59543382085f9eb51f8e87bac26bf96b164839955f244d07125a982ef"}, + {file = "ruff-0.4.10-py3-none-musllinux_1_2_i686.whl", hash = "sha256:3cea07079962b2941244191569cf3a05541477286f5cafea638cd3aa94b56815"}, + {file = "ruff-0.4.10-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:338a64ef0748f8c3a80d7f05785930f7965d71ca260904a9321d13be24b79695"}, + {file = "ruff-0.4.10-py3-none-win32.whl", hash = "sha256:ffe3cd2f89cb54561c62e5fa20e8f182c0a444934bf430515a4b422f1ab7b7ca"}, + {file = "ruff-0.4.10-py3-none-win_amd64.whl", hash = "sha256:67f67cef43c55ffc8cc59e8e0b97e9e60b4837c8f21e8ab5ffd5d66e196e25f7"}, + {file = "ruff-0.4.10-py3-none-win_arm64.whl", hash = "sha256:dd1fcee327c20addac7916ca4e2653fbbf2e8388d8a6477ce5b4e986b68ae6c0"}, + {file = "ruff-0.4.10.tar.gz", hash = "sha256:3aa4f2bc388a30d346c56524f7cacca85945ba124945fe489952aadb6b5cd804"}, ] [[package]] @@ -749,13 +749,13 @@ files = [ [[package]] name = "typing-extensions" -version = "4.11.0" +version = "4.12.2" description = "Backported and Experimental Type Hints for Python 3.8+" optional = false python-versions = ">=3.8" files = [ - {file = "typing_extensions-4.11.0-py3-none-any.whl", hash = "sha256:c1f94d72897edaf4ce775bb7558d5b79d8126906a14ea5ed1635921406c0387a"}, - {file = "typing_extensions-4.11.0.tar.gz", hash = "sha256:83f085bd5ca59c80295fc2a82ab5dac679cbe02b9f33f7d83af68e241bea51b0"}, + {file = "typing_extensions-4.12.2-py3-none-any.whl", hash = "sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d"}, + {file = "typing_extensions-4.12.2.tar.gz", hash = "sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8"}, ] [[package]] diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..bdfc664 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,23 @@ +from pathlib import Path + +import pytest + + +def pytest_addoption(parser): + """Sets up optional argument to keep temporary testing directory.""" + parser.addoption( + "--keep-tmp", + action="store_true", + help="Keep temporary directory after testing. Useful for debugging.", + ) + + +@pytest.fixture(scope="class") +def pass_options(request): + """Adds optional argument to a test class.""" + request.cls.KEEP_TMP = request.config.getoption("--keep-tmp") + + +@pytest.fixture(scope="function", autouse=True) +def temp_output_dir(tmpdir_factory) -> Path: + return Path(tmpdir_factory.mktemp("tmp-")) diff --git a/tests/data/harmony/message.json b/tests/data/harmony/message.json new file mode 100644 index 0000000..21eb885 --- /dev/null +++ b/tests/data/harmony/message.json @@ -0,0 +1,16 @@ +{ + "sources": [{ + "collection": "C1234088182-EEDTEST" + }], + "format": { + "mime": "application/x-netcdf4" + }, + "subset": {}, + "requestId": "00001111-2222-3333-4444-555566667777", + "user": "jdoe", + "client": "harmony-example", + "isSynchronous": false, + "stagingLocation": "s3://example-bucket/public/some-org/some-service/some-uuid/", + "callback": "http://localhost/some-path", + "version": "0.10.0" +} diff --git a/tests/data/harmony/source/catalog.json b/tests/data/harmony/source/catalog.json new file mode 100644 index 0000000..fd99944 --- /dev/null +++ b/tests/data/harmony/source/catalog.json @@ -0,0 +1,48 @@ +{ + "stac_version": "1.0.0-beta.2", + "stac_extensions": [], + "id": "cfc32383-cfd1-4e43-8d5f-55f539b6fa59", + "links": [ + { + "rel": "harmony_source", + "href": "https://cmr.uat.earthdata.nasa.gov/search/concepts/C1234088182-EEDTEST" + }, + { + "rel": "item", + "href": "./granule_S012G01.json", + "type": "application/json", + "title": "granule_S012G01" + }, + { + "rel": "item", + "href": "./granule_S012G02.json", + "type": "application/json", + "title": "granule_S012G02" + }, + { + "rel": "item", + "href": "./granule_S013G01.json", + "type": "application/json", + "title": "granule_S013G01" + }, + { + "rel": "item", + "href": "./granule_S013G02.json", + "type": "application/json", + "title": "granule_S013G02" + }, + { + "rel": "item", + "href": "./granule_S014G01.json", + "type": "application/json", + "title": "granule_S014G01" + }, + { + "rel": "item", + "href": "./granule_S014G02.json", + "type": "application/json", + "title": "granule_S014G02" + } + ], + "description": "CMR Granules for C1234088182-EEDTEST batch 1" +} diff --git a/tests/data/harmony/source/catalog0.json b/tests/data/harmony/source/catalog0.json new file mode 100644 index 0000000..009421c --- /dev/null +++ b/tests/data/harmony/source/catalog0.json @@ -0,0 +1,36 @@ +{ + "stac_version": "1.0.0-beta.2", + "stac_extensions": [], + "id": "cfc32383-cfd1-4e43-8d5f-55f539b6fa59", + "links": [ + { + "rel": "harmony_source", + "href": "https://cmr.uat.earthdata.nasa.gov/search/concepts/C1234088182-EEDTEST" + }, + { + "rel": "item", + "href": "./granule_S012G01.json", + "type": "application/json", + "title": "granule_S012G01" + }, + { + "rel": "item", + "href": "./granule_S012G02.json", + "type": "application/json", + "title": "granule_S012G02" + }, + { + "rel": "item", + "href": "./granule_S013G01.json", + "type": "application/json", + "title": "granule_S013G01" + }, + { + "rel": "next", + "href": "tests/data/harmony/source/catalog1.json", + "type": "application/json", + "title": "Next page" + } + ], + "description": "CMR Granules for C1234088182-EEDTEST batch 1" +} diff --git a/tests/data/harmony/source/catalog1.json b/tests/data/harmony/source/catalog1.json new file mode 100644 index 0000000..c844b16 --- /dev/null +++ b/tests/data/harmony/source/catalog1.json @@ -0,0 +1,36 @@ +{ + "stac_version": "1.0.0-beta.2", + "stac_extensions": [], + "id": "cfc32383-cfd1-4e43-8d5f-55f539b6fa59", + "links": [ + { + "rel": "harmony_source", + "href": "https://cmr.uat.earthdata.nasa.gov/search/concepts/C1234088182-EEDTEST" + }, + { + "rel": "item", + "href": "./granule_S013G02.json", + "type": "application/json", + "title": "granule_S013G02" + }, + { + "rel": "item", + "href": "./granule_S014G01.json", + "type": "application/json", + "title": "granule_S014G01" + }, + { + "rel": "item", + "href": "./granule_S014G02.json", + "type": "application/json", + "title": "granule_S014G02" + }, + { + "rel": "prev", + "href": "tests/data/harmony/source/catalog0.json", + "type": "application/json", + "title": "Previous page" + } + ], + "description": "CMR Granules for C1234088182-EEDTEST batch 2" +} diff --git a/tests/data/harmony/source/granule_S012G01.json b/tests/data/harmony/source/granule_S012G01.json new file mode 100644 index 0000000..f468f54 --- /dev/null +++ b/tests/data/harmony/source/granule_S012G01.json @@ -0,0 +1,49 @@ +{ + "stac_version": "1.0.0-beta.2", + "stac_extensions": [], + "id": "51d02b24-d00e-4640-9887-05f98f6b96d8", + "type": "Feature", + "links": [], + "properties": { + "start_datetime": "2020-01-02T00:00:00.000Z", + "end_datetime": "2020-01-02T23:59:59.000Z" + }, + "bbox": [1, 3, 1, 3], + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -179.95, + -89.95 + ], + [ + -179.95, + 89.95 + ], + [ + 179.95, + 89.95 + ], + [ + 179.95, + -89.95 + ], + [ + -179.95, + -89.95 + ] + ] + ] + }, + "assets": { + "data": { + "href": "file://tests/data/harmony/granules/TEMPO_NO2_L2_V03_20240601T120101Z_S012G01.nc", + "title": "TEMPO_NO2_L2_V03_20240601T120101Z_S012G01.nc", + "type": "application/x-netcdf4", + "roles": [ + "data" + ] + } + } +} diff --git a/tests/data/harmony/source/granule_S012G02.json b/tests/data/harmony/source/granule_S012G02.json new file mode 100644 index 0000000..1d25a15 --- /dev/null +++ b/tests/data/harmony/source/granule_S012G02.json @@ -0,0 +1,49 @@ +{ + "stac_version": "1.0.0-beta.2", + "stac_extensions": [], + "id": "21eb7dc5-7a9d-4374-9a88-12451ba653ef", + "type": "Feature", + "links": [], + "properties": { + "start_datetime": "2020-01-03T00:00:00.000Z", + "end_datetime": "2020-01-03T23:59:59.000Z" + }, + "bbox": [-1, -3, -1, -3], + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -179.95, + -89.95 + ], + [ + -179.95, + 89.95 + ], + [ + 179.95, + 89.95 + ], + [ + 179.95, + -89.95 + ], + [ + -179.95, + -89.95 + ] + ] + ] + }, + "assets": { + "data": { + "href": "file://tests/data/harmony/granules/TEMPO_NO2_L2_V03_20240601T120107Z_S012G02.nc", + "title": "TEMPO_NO2_L2_V03_20240601T120107Z_S012G02.nc", + "type": "application/x-netcdf4", + "roles": [ + "data" + ] + } + } +} diff --git a/tests/data/harmony/source/granule_S013G01.json b/tests/data/harmony/source/granule_S013G01.json new file mode 100644 index 0000000..c22cbc2 --- /dev/null +++ b/tests/data/harmony/source/granule_S013G01.json @@ -0,0 +1,49 @@ +{ + "stac_version": "1.0.0-beta.2", + "stac_extensions": [], + "id": "dc07a25a-54bd-4389-97b6-c1d68cf0d586", + "type": "Feature", + "links": [], + "properties": { + "start_datetime": "2020-01-05T00:00:00.000Z", + "end_datetime": "2020-01-05T23:59:59.000Z" + }, + "bbox": [-4, -2, -4, 2], + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -179.95, + -89.95 + ], + [ + -179.95, + 89.95 + ], + [ + 179.95, + 89.95 + ], + [ + 179.95, + -89.95 + ], + [ + -179.95, + -89.95 + ] + ] + ] + }, + "assets": { + "data": { + "href": "file://tests/data/harmony/granules/TEMPO_NO2_L2_V03_20240601T120202Z_S013G01.nc", + "title": "TEMPO_NO2_L2_V03_20240601T120202Z_S013G01.nc", + "type": "application/x-netcdf4", + "roles": [ + "data" + ] + } + } +} diff --git a/tests/data/harmony/source/granule_S013G02.json b/tests/data/harmony/source/granule_S013G02.json new file mode 100644 index 0000000..98d22f9 --- /dev/null +++ b/tests/data/harmony/source/granule_S013G02.json @@ -0,0 +1,49 @@ +{ + "stac_version": "1.0.0-beta.2", + "stac_extensions": [], + "id": "53cdf09b-4004-4405-9363-f93455a11c2f", + "type": "Feature", + "links": [], + "properties": { + "start_datetime": "2020-01-04T00:00:00.000Z", + "end_datetime": "2020-01-04T23:59:59.000Z" + }, + "bbox": [4, 2, 4, 2], + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -179.95, + -89.95 + ], + [ + -179.95, + 89.95 + ], + [ + 179.95, + 89.95 + ], + [ + 179.95, + -89.95 + ], + [ + -179.95, + -89.95 + ] + ] + ] + }, + "assets": { + "data": { + "href": "file://tests/data/harmony/granules/TEMPO_NO2_L2_V03_20240601T120209Z_S013G02.nc", + "title": "TEMPO_NO2_L2_V03_20240601T120209Z_S013G02.nc", + "type": "application/x-netcdf4", + "roles": [ + "data" + ] + } + } +} diff --git a/tests/data/harmony/source/granule_S014G01.json b/tests/data/harmony/source/granule_S014G01.json new file mode 100644 index 0000000..8800f8a --- /dev/null +++ b/tests/data/harmony/source/granule_S014G01.json @@ -0,0 +1,49 @@ +{ + "stac_version": "1.0.0-beta.2", + "stac_extensions": [], + "id": "349b5f4a-34ab-4b0d-ae00-b55fe3d166fb", + "type": "Feature", + "links": [], + "properties": { + "start_datetime": "2020-01-05T00:00:00.000Z", + "end_datetime": "2020-01-05T23:59:59.000Z" + }, + "bbox": [-5, -3, -5, 3], + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -179.95, + -89.95 + ], + [ + -179.95, + 89.95 + ], + [ + 179.95, + 89.95 + ], + [ + 179.95, + -89.95 + ], + [ + -179.95, + -89.95 + ] + ] + ] + }, + "assets": { + "data": { + "href": "file://tests/data/harmony/granules/TEMPO_NO2_L2_V03_20240601T120303Z_S014G01.nc", + "title": "TEMPO_NO2_L2_V03_20240601T120303Z_S014G01.nc", + "type": "application/x-netcdf4", + "roles": [ + "data" + ] + } + } +} diff --git a/tests/data/harmony/source/granule_S014G02.json b/tests/data/harmony/source/granule_S014G02.json new file mode 100644 index 0000000..6f6dffc --- /dev/null +++ b/tests/data/harmony/source/granule_S014G02.json @@ -0,0 +1,49 @@ +{ + "stac_version": "1.0.0-beta.2", + "stac_extensions": [], + "id": "cb0271ad-05a9-4138-8bfb-fa6b83fbe6fa", + "type": "Feature", + "links": [], + "properties": { + "start_datetime": "2020-01-05T00:00:00.000Z", + "end_datetime": "2020-01-05T23:59:59.000Z" + }, + "bbox": [5, 3, 5, 3], + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -179.95, + -89.95 + ], + [ + -179.95, + 89.95 + ], + [ + 179.95, + 89.95 + ], + [ + 179.95, + -89.95 + ], + [ + -179.95, + -89.95 + ] + ] + ] + }, + "assets": { + "data": { + "href": "file://tests/data/harmony/granules/TEMPO_NO2_L2_V03_20240601T120310Z_S014G02.nc", + "title": "TEMPO_NO2_L2_V03_20240601T120310Z_S014G02.nc", + "type": "application/x-netcdf4", + "roles": [ + "data" + ] + } + } +} diff --git a/tests/test_filename_grouping.py b/tests/test_filename_grouping.py index 83ae365..368e168 100644 --- a/tests/test_filename_grouping.py +++ b/tests/test_filename_grouping.py @@ -1,3 +1,7 @@ +import sys +from unittest.mock import patch + +import batcher.tempo_filename_parser from batcher.tempo_filename_parser import get_batch_indices example_filenames = [ @@ -14,3 +18,13 @@ def test_grouping(): results = get_batch_indices(example_filenames) assert results == [0, 0, 0, 1, 1, 1] + + +def test_main_cli(): + test_args = [batcher.tempo_filename_parser.__file__, "-v"] + test_args.extend(example_filenames) + + with patch.object(sys, "argv", test_args): + grouped_names = batcher.tempo_filename_parser.main() + + assert grouped_names == [example_filenames[0:3], example_filenames[3:6]] diff --git a/tests/test_harmony_adapter.py b/tests/test_harmony_adapter.py new file mode 100644 index 0000000..2726a6e --- /dev/null +++ b/tests/test_harmony_adapter.py @@ -0,0 +1,101 @@ +import json +import sys +from os import environ +from pathlib import Path +from unittest.mock import patch +from urllib.parse import urlsplit + +import pytest + +import batcher.harmony.cli + + +@pytest.mark.usefixtures("pass_options") +class TestBatching: + __test_path = Path(__file__).parent.resolve() + __data_path = __test_path.joinpath("data") + __harmony_path = __data_path.joinpath("harmony") + + def test_service_invoke(self, temp_output_dir): + in_message_path = self.__harmony_path.joinpath("message.json") + in_message_data = in_message_path.read_text() + + # test with both paged catalogs and un-paged catalogs + for in_catalog_name in ["catalog.json", "catalog0.json"]: + + in_catalog_path = self.__harmony_path.joinpath("source", in_catalog_name) + + test_args = [ + batcher.harmony.cli.__file__, + "--harmony-action", + "invoke", + "--harmony-input", + in_message_data, + "--harmony-source", + str(in_catalog_path), + "--harmony-metadata-dir", + str(temp_output_dir), + "--harmony-data-location", + temp_output_dir.as_uri(), + ] + + test_env = { + "ENV": "dev", + "OAUTH_CLIENT_ID": "", + "OAUTH_UID": "", + "OAUTH_PASSWORD": "", + "OAUTH_REDIRECT_URI": "", + "STAGING_PATH": "", + "STAGING_BUCKET": "", + } + + with patch.object(sys, "argv", test_args), patch.dict(environ, test_env): + batcher.harmony.cli.main() + + # Open the outputs + out_batch_catalog_path = temp_output_dir.joinpath("batch-catalogs.json") + out_batch_catalogs = json.loads(out_batch_catalog_path.read_text()) + + # Go through each batched catalog + batched_files = {0: [], 1: [], 2: []} + for batch_index, catalog in enumerate(out_batch_catalogs): + out_catalog_path = temp_output_dir.joinpath(catalog) + out_catalog = json.loads(out_catalog_path.read_text()) + + for item_meta in out_catalog["links"]: + if item_meta["rel"] == "item": + item_path = temp_output_dir.joinpath(item_meta["href"]).resolve() + + # -- Item Verification -- + item = json.loads(item_path.read_text()) + properties = item["properties"] + assert item["bbox"] + assert properties["start_datetime"] + assert properties["end_datetime"] + + # -- Asset Verification -- + data = item["assets"]["data"] + + # Sanity checks on metadata + assert data["type"] == "application/x-netcdf4" + assert data["roles"] == ["data"] + + batched_files[batch_index].append(Path(urlsplit(data["href"]).path).stem) + + # -- batch file list verification -- + files_dict = { + 0: [ + "TEMPO_NO2_L2_V03_20240601T120101Z_S012G01", + "TEMPO_NO2_L2_V03_20240601T120107Z_S012G02", + ], + 1: [ + "TEMPO_NO2_L2_V03_20240601T120202Z_S013G01", + "TEMPO_NO2_L2_V03_20240601T120209Z_S013G02", + ], + 2: [ + "TEMPO_NO2_L2_V03_20240601T120303Z_S014G01", + "TEMPO_NO2_L2_V03_20240601T120310Z_S014G02", + ], + } + + assert batched_files == files_dict