Skip to content
Snippets Groups Projects
Commit 702a9eb6 authored by Benjamin Becker's avatar Benjamin Becker
Browse files

adds alternative version of relationships to collection helpers

parent 35d44743
No related branches found
No related tags found
No related merge requests found
......@@ -24,8 +24,11 @@ def get_collection_info(collection_id, dataset_dict=None):
def get_collection_id(dataset_dict):
relationships_dataset = dataset_dict.get('relationships_as_subject')
if len(relationships_dataset):
if relationships_dataset and len(relationships_dataset):
return relationships_dataset[0]['__extras']['object_package_id']
relationships_dataset = dataset_dict.get('relationships')
if relationships_dataset and len(relationships_dataset):
return relationships_dataset[0].get('object')
return None
......
......@@ -122,6 +122,15 @@ class TestHelpersCollection(object):
collection_id = helpers_collection.get_collection_id(dataset_dict)
nt.assert_equal(collection_id, 'some_id')
def test_get_collection_id_if_in_collection_alternative_version(self):
dataset_dict = {
'relationships': [
{'object': 'some_id'}
]
}
collection_id = helpers_collection.get_collection_id(dataset_dict)
nt.assert_equal(collection_id, 'some_id')
def test_get_collection_id_if_NOT_in_collection(self):
dataset_dict = {
'relationships_as_subject': []
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment