From: Fuad Muhic Date: Wed, 23 May 2018 10:05:41 +0000 (+0200) Subject: Added test that checks that saving a committed collection updates the storage_classes... X-Git-Tag: 1.2.0~141^2 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/02b02bfb39344eb28730646f645f1a335fcc6ae2?hp=-c Added test that checks that saving a committed collection updates the storage_classes_desired Arvados-DCO-1.1-Signed-off-by: Fuad Muhic --- 02b02bfb39344eb28730646f645f1a335fcc6ae2 diff --git a/sdk/python/arvados/collection.py b/sdk/python/arvados/collection.py index 376e059244..e390a60a87 100644 --- a/sdk/python/arvados/collection.py +++ b/sdk/python/arvados/collection.py @@ -1458,6 +1458,8 @@ class Collection(RichCollectionBase): Retry count on API calls (if None, use the collection default) """ + if storage_classes and type(storage_classes) is not list: + raise errors.ArgumentError("storage_classes must be list type.") if not self.committed(): if not self._has_collection_uuid(): @@ -1471,8 +1473,6 @@ class Collection(RichCollectionBase): text = self.manifest_text(strip=False) body={'manifest_text': text} if storage_classes: - if type(storage_classes) is not list: - raise errors.ArgumentError("storage_classes must be list type.") body["storage_classes_desired"] = storage_classes self._remember_api_response(self._my_api().collections().update( @@ -1484,8 +1484,6 @@ class Collection(RichCollectionBase): self._portable_data_hash = self._api_response["portable_data_hash"] self.set_committed(True) elif storage_classes: - if type(storage_classes) is not list: - raise errors.ArgumentError("storage_classes must be list type.") self._remember_api_response(self._my_api().collections().update( uuid=self._manifest_locator, body={"storage_classes_desired": storage_classes} diff --git a/sdk/python/tests/test_collections.py b/sdk/python/tests/test_collections.py index 736994c671..a56d4f68f1 100644 --- a/sdk/python/tests/test_collections.py +++ b/sdk/python/tests/test_collections.py @@ -1317,6 +1317,13 @@ class CollectionCreateUpdateTest(run_test_server.TestCaseWithServers): r"^\. 781e5e245d69b566979b86e28d23f2c7\+10\+A[a-f0-9]{40}@[a-f0-9]{8} 0:10:count\.txt$",) self.assertEqual(c.api_response()["storage_classes_desired"], ['archive']) + def test_update_storage_classes_desired_if_collection_is_commited(self): + c = self.create_count_txt() + c.save(storage_classes=['hot']) + c.save(storage_classes=['cold']) + + self.assertEqual(c.api_response()["storage_classes_desired"], ['cold']) + def test_create_diff_apply(self): c1 = self.create_count_txt() c1.save()