def test_empty_enabled_disabled(self): # pylint: disable=no-self-use """Test that `aiida.manage.caching.configure` does not except when either `enabled` or `disabled` is `None`. This will happen when the configuration file specifies either one of the keys but no actual values, e.g.:: profile_name: default: False enabled: In this case, the dictionary parsed by yaml will contain `None` for the `enabled` key. Now this will be unlikely, but the same holds when all values are commented:: profile_name: default: False enabled: # - aiida.calculations:templatereplacer which is not unlikely to occurr in the wild. """ configuration = { get_profile().name: { 'default': True, 'enabled': None, 'disabled': None } } with tempfile.NamedTemporaryFile() as handle: yaml.dump(configuration, handle, encoding='utf-8') configure(config_file=handle.name) # Check that `get_use_cache` also does not except get_use_cache(identifier='aiida.calculations:templatereplacer')
def inner(config_dict): with tempfile.NamedTemporaryFile() as handle: yaml.dump({get_profile().name: config_dict}, handle, encoding='utf-8') configure(config_file=handle.name) yield # reset the configuration configure()
def load_configuration(identifier): """Write the caching file for given configuration and load it.""" configuration = { get_profile().name: { 'default': True, 'enabled': [identifier] } } with tempfile.NamedTemporaryFile() as handle: yaml.dump(configuration, handle, encoding='utf-8') configure(config_file=handle.name)
def setUp(self): """Write a temporary config file, and load the configuration.""" self.config_reference = { get_profile().name: { 'default': True, 'enabled': ['aiida.calculations:arithmetic.add'], 'disabled': ['aiida.calculations:templatereplacer'] } } with tempfile.NamedTemporaryFile() as handle: yaml.dump(self.config_reference, handle, encoding='utf-8') configure(config_file=handle.name)
def tearDown(self): # pylint: disable=no-self-use """Reset the configuration.""" configure()