|
| 1 | +import unittest |
| 2 | + |
| 3 | +import irods.client_configuration as cfg |
| 4 | + |
| 5 | + |
| 6 | +# Test assignments on the negative and positive space of the |
| 7 | +# client configuration. |
| 8 | +class TestClientConfigurationAttributes(unittest.TestCase): |
| 9 | + def test_configuration_writes_and_miswrites__issue_708(self): |
| 10 | + # For caching configuration objects |
| 11 | + configuration_level = {} |
| 12 | + leaf_names = [] |
| 13 | + |
| 14 | + for dotted_name, value, is_conf in cfg._var_items_as_generator(): |
| 15 | + with self.subTest(dotted_name=dotted_name): |
| 16 | + name_parts = dotted_name.split('.') |
| 17 | + namespace = '.'.join(name_parts[:-1]) |
| 18 | + attribute_name = name_parts[-1] |
| 19 | + if isinstance(value, cfg.iRODSConfiguration): |
| 20 | + configuration_level[dotted_name] = value |
| 21 | + elif is_conf: |
| 22 | + leaf_names.append(attribute_name) |
| 23 | + |
| 24 | + # Test the positive space, i.e. the 'hit' |
| 25 | + setattr(configuration_level[namespace], attribute_name, value) |
| 26 | + |
| 27 | + # Test the negative space, i.e. the 'miss' |
| 28 | + with self.assertRaises(AttributeError): |
| 29 | + setattr(configuration_level[namespace], attribute_name + '_1', value) |
| 30 | + |
| 31 | + # These cases were identified as likely ones for possible failed writes via misspelling. |
| 32 | + self.assertIn('irods_query_limit', leaf_names) |
| 33 | + self.assertIn('xml_parser_default', leaf_names) |
0 commit comments