generated from NASA-PDS/template-repo-java
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from NASA-PDS/version_140
Version 1.5.0
- Loading branch information
Showing
10 changed files
with
138 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/pds/api_client/test/integration/test_collections_of_bundle.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import unittest | ||
from pds.api_client import Configuration | ||
from pds.api_client import ApiClient | ||
from pds.api_client.api.product_references_api import ProductReferencesApi | ||
|
||
|
||
class CollectionsOfBundleTestCase(unittest.TestCase): | ||
def setUp(self): | ||
# create an instance of the API class | ||
configuration = Configuration() | ||
configuration.host = 'http://localhost:8080' | ||
api_client = ApiClient(configuration) | ||
self.product_reference = ProductReferencesApi(api_client) | ||
|
||
def test_collections_of_a_bundle_default(self): | ||
|
||
results = self.product_reference.product_members( | ||
'urn:nasa:pds:mars2020.spice::3.0', | ||
fields=['ops:Data_File_Info.ops:file_ref'] | ||
) | ||
for collection in results.data: | ||
urls = collection.properties['ops:Data_File_Info.ops:file_ref'] | ||
for url in urls: | ||
print(url) | ||
|
||
def test_all_collections_of_a_bundle_as_deep_archive_does(self): | ||
|
||
def get_collections(bundle_lidvid): | ||
_apiquerylimit = 50 | ||
_propdataurl = "ops:Data_File_Info.ops:file_ref" | ||
_propdatamd5 = "ops:Data_File_Info.ops:md5_checksum" | ||
_proplabelurl = "ops:Label_File_Info.ops:file_ref" | ||
_proplabelmd5 = "ops:Label_File_Info.ops:md5_checksum" | ||
_proplabelharvesttime = "ops:Harvest_Info.ops:harvest_date_time" | ||
_fields = [_propdataurl, _propdatamd5, _proplabelurl, _proplabelmd5, _proplabelharvesttime] | ||
|
||
full_page = True | ||
|
||
kwargs = dict( | ||
sort=['ops:Harvest_Info.ops:harvest_date_time'], | ||
limit=_apiquerylimit, | ||
fields=_fields | ||
) | ||
|
||
while full_page: | ||
page = self.product_reference.product_members(bundle_lidvid, **kwargs) | ||
full_page = len(page.data) == _apiquerylimit | ||
for c in page.data: | ||
yield c | ||
kwargs['search_after'] = page.data[-1].properties['ops:Harvest_Info.ops:harvest_date_time'][0] | ||
|
||
n = 0 | ||
for collection in get_collections("urn:nasa:pds:mars2020.spice::3.0"): | ||
print(collection.id) | ||
n += 1 | ||
|
||
assert n == 1 | ||
|
||
def test_collection_members(self): | ||
results = self.product_reference.product_members( | ||
'urn:nasa:pds:mars2020.spice:spice_kernels::3.0' | ||
) | ||
|
||
self.assertEqual(len(results.data), 11) # add assertion here | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import unittest | ||
from pds.api_client import Configuration | ||
from pds.api_client import ApiClient | ||
|
||
from pds.api_client.api.all_products_api import AllProductsApi | ||
|
||
|
||
class PaginationTestCase(unittest.TestCase): | ||
def setUp(self): | ||
# create an instance of the API class | ||
configuration = Configuration() | ||
configuration.host = 'http://localhost:8080' | ||
api_client = ApiClient(configuration) | ||
self.products = AllProductsApi(api_client) | ||
|
||
def test_pages(self): | ||
results_1 = self.products.product_list( | ||
keywords=['kernel'], | ||
sort=['ops:Harvest_Info.ops:harvest_date_time'], | ||
limit=2 | ||
) | ||
|
||
self.assertEqual(len(results_1.data), 2) # 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'], | ||
sort=['ops:Harvest_Info.ops:harvest_date_time'], | ||
search_after=[latest_harvest_date_time], | ||
limit=2 | ||
) | ||
|
||
self.assertEqual(len(results_2.data), 1) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters