def parse_key_configurator(config): """Return a properly configured KeyConfigurator from 'config'.""" matcher, config = extract_matcher(config) try: return KeyConfigurator(matcher=matcher, **config) except TypeError as e: raise convert_type_error(e)
def test_key_configurator_configure_key(): c = KeyConfigurator() c.reduced_redundancy = True c.encrypted = False c.cache_control = 'test' c.canned_acl = 'public-read' c.metadata = {'some':'metadata'} # Create new key and run configurator on it k = Key(None, 'bucket', 'key', canned_acl='private', encrypted=True, metadata={'some':'otherdata'}, cache_control='original') k = c.configure_key(k) # Confirm configurator worked as expected assert k.reduced_redundancy assert not k.encrypted assert k.cache_control == 'test' assert k.canned_acl == 'public-read' assert k.metadata['some'] == 'metadata'
def test_key_configurator_configure_key(): c = KeyConfigurator() c.reduced_redundancy = True c.encrypted = False c.cache_control = 'test' c.canned_acl = 'public-read' c.metadata = {'some': 'metadata'} # Create new key and run configurator on it k = Key(None, 'bucket', 'key', canned_acl='private', encrypted=True, metadata={'some': 'otherdata'}, cache_control='original') k = c.configure_key(k) # Confirm configurator worked as expected assert k.reduced_redundancy assert not k.encrypted assert k.cache_control == 'test' assert k.canned_acl == 'public-read' assert k.metadata['some'] == 'metadata'
def test_key_configurator_effects_key(): c = KeyConfigurator(matcher=Matcher(['*.py'])) assert c.effects_key('test.py') assert not c.effects_key('test.md')