Skip to content

Commit

Permalink
Support collection search by processing_level_id
Browse files Browse the repository at this point in the history
Fixes #76 

---------

Co-authored-by: Chuck Daniels <chuck@developmentseed.org>
  • Loading branch information
WardBrian and chuckwondo authored Aug 30, 2024
1 parent 8a2d926 commit b03f9a0
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
other parameter options that are not covered in that particular section of the
documentation. ([#74](https://github.com/nasa/python_cmr/issues/74))
- Support multi-point searches ([#72](https://github.com/nasa/python_cmr/issues/72))
- Support `processing_level_id` in `CollectionQuery` ([#76](https://github.com/nasa/python_cmr/issues/76))
- Support `platform` in `CollectionQuery` ([#77](https://github.com/nasa/python_cmr/issues/77))

### Fixed
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ api.tool_concept_id('TL2092786348-POCLOUD')

# filter by service concept id
api.service_concept_id('S1962070864-POCLOUD')

# filter by processing level id
api.processing_level_id('3')
```

Service searches support the following methods
Expand Down
17 changes: 17 additions & 0 deletions cmr/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,23 @@ def cloud_hosted(self, cloud_hosted: bool) -> Self:

return self

def processing_level_id(self, IDs: Union[str, Sequence[str]]) -> Self:
"""
Filter collections matching processing level ID (ex: 2)
Collections are associated with this processing level ID.
:param IDs: processing level ID(s) to search by. Can be provided as a string or list of strings.
:returns: self
"""

if isinstance(IDs, str):
IDs = [IDs]

self.params["processing_level_id"] = IDs

return self

@override
def _valid_state(self) -> bool:
return True
Expand Down
14 changes: 14 additions & 0 deletions tests/test_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,20 @@ def test_invalid_concept_id(self):
with self.assertRaises(ValueError):
query.concept_id(["C1299783579-LPDAAC_ECS", "G1327299284-LPDAAC_ECS"])

def test_processing_level_id(self):
query = CollectionQuery()
query.processing_level_id("2")

self.assertIn("processing_level_id", query.params)
self.assertEqual(query.params["processing_level_id"], ["2"])

def test_processing_level_ids(self):
query = CollectionQuery()
query.processing_level_id(["2", "3"])

self.assertIn("processing_level_id", query.params)
self.assertEqual(query.params["processing_level_id"], ["2", "3"])

def test_token(self):
query = CollectionQuery()

Expand Down

0 comments on commit b03f9a0

Please sign in to comment.