generated from NASA-PDS/template-repo-java
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Version 1.5.0 #33
Merged
Merged
Version 1.5.0 #33
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @nutjob4life ,
This is the piece of code which tested the pagination as you do in deep-archive.
I will add a reference to here in the deep-archive ticket. Unfortunatly, I missed to commit the previous version of this code, so it will not be as easy for you to see the changes.