|
6 | 6 | import time |
7 | 7 | import datetime |
8 | 8 | import unittest |
9 | | -from irods.meta import (iRODSMeta, AVUOperation, BadAVUOperationValue, BadAVUOperationKeyword) |
| 9 | +import irods.exception as ex |
10 | 10 | from irods.manager.metadata_manager import InvalidAtomicAVURequest |
| 11 | +from irods.meta import (iRODSMeta, AVUOperation, BadAVUOperationValue, BadAVUOperationKeyword) |
11 | 12 | from irods.models import (DataObject, Collection, Resource, CollectionMeta) |
12 | 13 | import irods.test.helpers as helpers |
13 | 14 | import irods.keywords as kw |
@@ -119,7 +120,39 @@ def tearDown(self): |
119 | 120 | helpers.remove_unused_metadata(self.sess) |
120 | 121 | self.sess.cleanup() |
121 | 122 |
|
122 | | - from irods.test.helpers import create_simple_resc_hierarchy |
| 123 | + from irods.test.helpers import (create_simple_resc, create_simple_resc_hierarchy) |
| 124 | + |
| 125 | + def test_replica_truncate_json_error__issue_606(self): |
| 126 | + path = self.coll_path + "/atomic_meta_issue_606" |
| 127 | + obj = self.sess.data_objects.create(path) |
| 128 | + with self.create_simple_resc('repl_trunc_test_resc__issue_606') as f: |
| 129 | + try: |
| 130 | + obj.replica_truncate(1,**{kw.RESC_NAME_KW:f}) |
| 131 | + except ex.iRODSException as e: |
| 132 | + resp = e.server_msg.get_json_encoded_struct() |
| 133 | + # Test that returned structure is a dict containing at least one item. |
| 134 | + self.assertIsInstance(resp, dict) |
| 135 | + self.assertTrue(resp) |
| 136 | + |
| 137 | + def test_atomic_metadata_json_error__issue_606(self): |
| 138 | + path = self.coll_path + "/atomic_meta_issue_606" |
| 139 | + obj = self.sess.data_objects.create(path) |
| 140 | + obj.unlink(force = True) |
| 141 | + fail_message = '' |
| 142 | + try: |
| 143 | + obj.metadata.apply_atomic_operations(AVUOperation(operation="add", avu=iRODSMeta('a','b','c'))) |
| 144 | + except ex.iRODSException as e: |
| 145 | + resp = e.server_msg.get_json_encoded_struct() |
| 146 | + self.assertIn( |
| 147 | + 'Entity does not exist [entity_name={}]'.format(obj.path), |
| 148 | + resp['error_message']) |
| 149 | + except Exception as e: |
| 150 | + fail_message = 'apply_atomic_operations on a nonexistent object raised an unexpected exception {e!r}'.format(**locals()) |
| 151 | + else: |
| 152 | + fail_message = 'apply_atomic_operations on a nonexistent object did not raise an exception as expected.' |
| 153 | + |
| 154 | + if fail_message: |
| 155 | + self.fail(fail_message) |
123 | 156 |
|
124 | 157 | def test_atomic_metadata_operations_244(self): |
125 | 158 | user = self.sess.users.get("rods") |
|
0 commit comments