Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add processing_level_id collection parameter #79

Merged
merged 3 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,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