Skip to content

Commit

Permalink
Merge pull request #37 from NASA-PDS/api150
Browse files Browse the repository at this point in the history
Updates to comply with API version 1.5.0
  • Loading branch information
tloubrieu-jpl authored Oct 24, 2024
2 parents 5fb4e0d + ba21021 commit 03dbef4
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 17 deletions.
7 changes: 5 additions & 2 deletions docs/source/developer/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ The reference OpenAPI specifications for PDS can be found on `PDS API`_.
Then, install OpenAPI Generator 6.5.0 (e.g. on macos with brew, see https://github.com/OpenAPITools/openapi-generator#1---installation), and run::

pip install pyyaml
rm -fr pds test
python src/pds/api_client/preprocess_openapi.py /Users/loubrieu/PycharmProjects/pds-api/specs/PDS_APIs-search-1.1.1-swagger.yaml --version 1.3.0
rm pds/__init__.py

Manual step, add lines in the setup.py file:

Expand Down Expand Up @@ -74,8 +76,9 @@ PyPI Publication

Try::

pip install wheel
python setup.py sdist bdist_wheel
rm -f dist/*
pip install build
python -m build .
pip install twine
twine upload --repository testpypi dist/*

Expand Down
4 changes: 3 additions & 1 deletion docs/source/quickstart/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ The package releases match with the `Search API specification <https://nasa-pds.

* - pds.api-client
- pds search api specification
* - 1.6.X
- 1.5
* - 1.5.X
- 1.4
* - 1.4.X
Expand Down Expand Up @@ -91,7 +93,7 @@ For Collections for example:
classes = ByProductClassesApi(api_client)
api_response = classes.class_list(
'collections',
'collection',
start=0,
limit=20,
fields=['ops:Label_File_Info.ops:file_ref']
Expand Down
8 changes: 5 additions & 3 deletions src/pds/api_client/preprocess_openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ def preprocess(input: dict):

new_tags_dict = {t['name']: t['name'][3:] for t in input['tags']}
for path in input['paths'].keys():
tags = input['paths'][path]['get']['tags']
new_tags = [new_tags_dict.get(tag, tag) for tag in tags]
input['paths'][path]['get']['tags'] = new_tags
for method in ['get', 'post']:
if method in input['paths'][path]:
tags = input['paths'][path][method]['tags']
new_tags = [new_tags_dict.get(tag, tag) for tag in tags]
input['paths'][path][method]['tags'] = new_tags

# remove the * object which is confusing for the api generator
for k, r in input['components']['responses'].items():
Expand Down
4 changes: 2 additions & 2 deletions src/pds/api_client/test/integration/test_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def setUp(self):
def test_all_collections(self):

api_response = self.product_by_class.class_list(
'collections',
'collection',
limit=10
)

Expand All @@ -38,7 +38,7 @@ def test_all_collections(self):

def test_all_collections_one_property(self):
api_response = self.product_by_class.class_list(
'collections',
'collection',
limit=20,
fields=['ops:Label_File_Info.ops:file_ref']
)
Expand Down
12 changes: 6 additions & 6 deletions src/pds/api_client/test/integration/test_pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ def setUp(self):

def test_pages(self):
results_1 = self.products.product_list(
keywords=['kernel'],
q='ref_lid_instrument eq "urn:nasa:pds:context:instrument:radiometer.insight"',
sort=['ops:Harvest_Info.ops:harvest_date_time'],
limit=2
limit=3
)

self.assertEqual(len(results_1.data), 2) # add assertion here
self.assertEqual(len(results_1.data), 3) # add assertion here

latest_harvest_date_time = results_1.data[-1].properties['ops:Harvest_Info.ops:harvest_date_time'][0]

results_2 = self.products.product_list(
keywords=['kernel'],
q='ref_lid_instrument eq "urn:nasa:pds:context:instrument:radiometer.insight"',
sort=['ops:Harvest_Info.ops:harvest_date_time'],
search_after=[latest_harvest_date_time],
limit=2
limit=3
)

self.assertEqual(len(results_2.data), 1)
self.assertEqual(len(results_2.data), 3)


if __name__ == '__main__':
Expand Down
6 changes: 3 additions & 3 deletions src/pds/api_client/test/integration/test_products.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ def test_get_properties(self):
properties_dict = {p.var_property:{"type": p.type} for p in properties}
assert '_package_id' in properties_dict.keys()
assert 'alternate_ids' in properties_dict.keys()
assert 'insight:Observation_Information/insight:software_version_id' in properties_dict.keys()
assert 'insight:Observation_Information.insight:software_version_id' in properties_dict.keys()
assert properties_dict['_package_id']['type'] == 'string'
assert properties_dict['alternate_ids']['type'] == 'string'
assert properties_dict['insight:Observation_Information/insight:software_version_id']['type'] == 'string'

assert properties_dict['insight:Observation_Information.insight:software_version_id']['type'] == 'string'

@unittest.skip("keyword is temporarily not implemented in version 1.5.0 of the API")
def test_products_by_keywords(self):
results = self.products.product_list(
keywords=['kernel']
Expand Down

0 comments on commit 03dbef4

Please sign in to comment.