Skip to content

Commit 5fb4e0d

Browse files
Merge pull request #33 from NASA-PDS/version_140
Version 1.5.0
2 parents 07cb521 + ec99e54 commit 5fb4e0d

File tree

10 files changed

+138
-24
lines changed

10 files changed

+138
-24
lines changed

docs/source/developer/index.rst

+15-13
Original file line numberDiff line numberDiff line change
@@ -41,32 +41,33 @@ The reference OpenAPI specifications for PDS can be found on `PDS API`_.
4141

4242
Then, install OpenAPI Generator 6.5.0 (e.g. on macos with brew, see https://github.com/OpenAPITools/openapi-generator#1---installation), and run::
4343

44+
pip install pyyaml
4445
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
4546

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

47-
Installation
48-
~~~~~~~~~~~~
49+
from setuptools import find_namespace_packages
4950

50-
Do the following commands in a Python virtual environment::
51+
packages=find_namespace_packages(where='src/', exclude=["test", "tests"]),
52+
package_dir={"": "src"},
5153

52-
pip install --requirement requirements.txt
53-
python setup.py install
5454

55+
Installation & Testing
56+
~~~~~~~~~~~~~~~~~~~~~~~
57+
For integration testing you need an Registry API local server deployed on http://localhost:8080
5558

56-
Testing
57-
~~~~~~~
59+
Use the docker compose deployment, see https://nasa-pds.github.io/registry/install/docker-compose.html
5860

59-
For testing you need an Registry API local server deployed on http://localhost:8080
61+
Do the following commands in a Python virtual environment::
6062

61-
Use the docker compose deployment, see https://nasa-pds.github.io/registry/install/docker-compose.html
63+
tox
6264

63-
To test it, try the virtual environment's Python::
6465

65-
python client-demo.py
66-
python setup.py test
66+
Run demo
67+
~~~~~~~~~
6768

69+
python src/pds/api_client/demo/client-demo.py
6870

69-
Note that you need an API server to test on.
7071

7172
PyPI Publication
7273
~~~~~~~~~~~~~~~~
@@ -75,6 +76,7 @@ Try::
7576

7677
pip install wheel
7778
python setup.py sdist bdist_wheel
79+
pip install twine
7880
twine upload --repository testpypi dist/*
7981

8082

docs/source/quickstart/index.rst

+3-6
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ Prerequisites
88
-------------
99

1010
Python 3 (tested with 3.9).
11-
<<<<<<< HEAD
12-
=======
1311

1412
Issues with SSL certificate verification seen with python 3.9.
1513

@@ -19,9 +17,6 @@ If it occurs to you, try:
1917

2018
However, we have not been able to solve that with conda python 3.9.
2119

22-
>>>>>>> 94a82f3 (wip: add test on properties, add new version compliance line)
23-
24-
2520

2621
Installation
2722
------------
@@ -38,6 +33,8 @@ The package releases match with the `Search API specification <https://nasa-pds.
3833

3934
* - pds.api-client
4035
- pds search api specification
36+
* - 1.5.X
37+
- 1.4
4138
* - 1.4.X
4239
- 1.3
4340
* - 1.3.X
@@ -51,7 +48,7 @@ The package releases match with the `Search API specification <https://nasa-pds.
5148

5249
To install a specific version of this package, run, for example::
5350

54-
pip install pds.api-client==1.3.0
51+
pip install pds.api-client==1.4.0
5552

5653

5754
You can also include it as a dependency in another package, for example, in

src/__init__.py

Whitespace-only changes.

src/pds/__init__.py

Whitespace-only changes.

src/pds/api_client/__init__.py

Whitespace-only changes.

src/pds/api_client/preprocess_openapi.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,16 @@ def run_openapi_gen(input, version):
3838
'generate',
3939
'--skip-validate-spec',
4040
'-g',
41-
'python-nextgen',
41+
'python',
4242
'-i',
4343
file.name,
4444
'--package-name',
4545
'pds.api_client',
4646
f'--additional-properties=packageVersion={version}'
4747
])
4848
subprocess.run(openapi_generator_cmd)
49+
# move the generated classes with the static code
50+
shutil.copytree('./pds/api_client', './src/pds/api_client', dirs_exist_ok=True)
4951

5052

5153
def main():

src/pds/api_client/test/integration/test_collections.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ def test_all_collections(self):
2020

2121
api_response = self.product_by_class.class_list(
2222
'collections',
23-
start=0,
2423
limit=10
2524
)
2625

@@ -40,14 +39,13 @@ def test_all_collections(self):
4039
def test_all_collections_one_property(self):
4140
api_response = self.product_by_class.class_list(
4241
'collections',
43-
start=0,
4442
limit=20,
4543
fields=['ops:Label_File_Info.ops:file_ref']
4644
)
4745

4846
assert hasattr(api_response, "data")
4947

50-
collections_expected_labels = iter([
48+
collections_expected_labels = set([
5149
"http://localhost:81/archive/custom-datasets/naif3/spice_kernels/collection_spice_kernels_v003.xml",
5250
"http://localhost:81/archive/custom-datasets/urn-nasa-pds-insight_rad/data_calibrated/collection_data_rad_calibrated.xml",
5351
"http://localhost:81/archive/custom-datasets/urn-nasa-pds-insight_rad/data_derived/collection_data_rad_derived.xml",
@@ -56,7 +54,9 @@ def test_all_collections_one_property(self):
5654

5755
for collection in api_response.data:
5856
urls = collection.properties['ops:Label_File_Info.ops:file_ref']
59-
assert next(collections_expected_labels) in urls[0]
57+
assert urls[0] in collections_expected_labels
58+
collections_expected_labels.discard(urls[0])
59+
6060

6161
def test_collection_by_lidvid_all(self):
6262
collections = self.all_products.select_by_lidvid_all('urn:nasa:pds:mars2020.spice:spice_kernels')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import unittest
2+
from pds.api_client import Configuration
3+
from pds.api_client import ApiClient
4+
from pds.api_client.api.product_references_api import ProductReferencesApi
5+
6+
7+
class CollectionsOfBundleTestCase(unittest.TestCase):
8+
def setUp(self):
9+
# create an instance of the API class
10+
configuration = Configuration()
11+
configuration.host = 'http://localhost:8080'
12+
api_client = ApiClient(configuration)
13+
self.product_reference = ProductReferencesApi(api_client)
14+
15+
def test_collections_of_a_bundle_default(self):
16+
17+
results = self.product_reference.product_members(
18+
'urn:nasa:pds:mars2020.spice::3.0',
19+
fields=['ops:Data_File_Info.ops:file_ref']
20+
)
21+
for collection in results.data:
22+
urls = collection.properties['ops:Data_File_Info.ops:file_ref']
23+
for url in urls:
24+
print(url)
25+
26+
def test_all_collections_of_a_bundle_as_deep_archive_does(self):
27+
28+
def get_collections(bundle_lidvid):
29+
_apiquerylimit = 50
30+
_propdataurl = "ops:Data_File_Info.ops:file_ref"
31+
_propdatamd5 = "ops:Data_File_Info.ops:md5_checksum"
32+
_proplabelurl = "ops:Label_File_Info.ops:file_ref"
33+
_proplabelmd5 = "ops:Label_File_Info.ops:md5_checksum"
34+
_proplabelharvesttime = "ops:Harvest_Info.ops:harvest_date_time"
35+
_fields = [_propdataurl, _propdatamd5, _proplabelurl, _proplabelmd5, _proplabelharvesttime]
36+
37+
full_page = True
38+
39+
kwargs = dict(
40+
sort=['ops:Harvest_Info.ops:harvest_date_time'],
41+
limit=_apiquerylimit,
42+
fields=_fields
43+
)
44+
45+
while full_page:
46+
page = self.product_reference.product_members(bundle_lidvid, **kwargs)
47+
full_page = len(page.data) == _apiquerylimit
48+
for c in page.data:
49+
yield c
50+
kwargs['search_after'] = page.data[-1].properties['ops:Harvest_Info.ops:harvest_date_time'][0]
51+
52+
n = 0
53+
for collection in get_collections("urn:nasa:pds:mars2020.spice::3.0"):
54+
print(collection.id)
55+
n += 1
56+
57+
assert n == 1
58+
59+
def test_collection_members(self):
60+
results = self.product_reference.product_members(
61+
'urn:nasa:pds:mars2020.spice:spice_kernels::3.0'
62+
)
63+
64+
self.assertEqual(len(results.data), 11) # add assertion here
65+
66+
67+
if __name__ == '__main__':
68+
unittest.main()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import unittest
2+
from pds.api_client import Configuration
3+
from pds.api_client import ApiClient
4+
5+
from pds.api_client.api.all_products_api import AllProductsApi
6+
7+
8+
class PaginationTestCase(unittest.TestCase):
9+
def setUp(self):
10+
# create an instance of the API class
11+
configuration = Configuration()
12+
configuration.host = 'http://localhost:8080'
13+
api_client = ApiClient(configuration)
14+
self.products = AllProductsApi(api_client)
15+
16+
def test_pages(self):
17+
results_1 = self.products.product_list(
18+
keywords=['kernel'],
19+
sort=['ops:Harvest_Info.ops:harvest_date_time'],
20+
limit=2
21+
)
22+
23+
self.assertEqual(len(results_1.data), 2) # add assertion here
24+
25+
latest_harvest_date_time = results_1.data[-1].properties['ops:Harvest_Info.ops:harvest_date_time'][0]
26+
27+
results_2 = self.products.product_list(
28+
keywords=['kernel'],
29+
sort=['ops:Harvest_Info.ops:harvest_date_time'],
30+
search_after=[latest_harvest_date_time],
31+
limit=2
32+
)
33+
34+
self.assertEqual(len(results_2.data), 1)
35+
36+
37+
if __name__ == '__main__':
38+
unittest.main()

src/pds/api_client/test/integration/test_products.py

+7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ def setUp(self):
1717
def test_get_properties(self):
1818

1919
properties = self.products.product_properties_list()
20+
properties_dict = {p.var_property:{"type": p.type} for p in properties}
21+
assert '_package_id' in properties_dict.keys()
22+
assert 'alternate_ids' in properties_dict.keys()
23+
assert 'insight:Observation_Information/insight:software_version_id' in properties_dict.keys()
24+
assert properties_dict['_package_id']['type'] == 'string'
25+
assert properties_dict['alternate_ids']['type'] == 'string'
26+
assert properties_dict['insight:Observation_Information/insight:software_version_id']['type'] == 'string'
2027

2128

2229
def test_products_by_keywords(self):

0 commit comments

Comments
 (0)