def test_apprise_config_instantiate(): """ API: AppriseConfig.instantiate() """ assert AppriseConfig.instantiate('file://?', suppress_exceptions=True) is None assert AppriseConfig.instantiate('invalid://?', suppress_exceptions=True) is None class BadConfig(ConfigBase): # always allow incusion allow_cross_includes = ContentIncludeMode.ALWAYS def __init__(self, **kwargs): super(BadConfig, self).__init__(**kwargs) # We fail whenever we're initialized raise TypeError() @staticmethod def parse_url(url, *args, **kwargs): # always parseable return ConfigBase.parse_url(url, verify_host=False) # Store our bad configuration in our schema map CONFIG_SCHEMA_MAP['bad'] = BadConfig with pytest.raises(TypeError): AppriseConfig.instantiate('bad://path', suppress_exceptions=False) # Same call but exceptions suppressed assert AppriseConfig.instantiate('bad://path', suppress_exceptions=True) is None
def test_apprise_config_instantiate(): """ API: AppriseConfig.instantiate() """ assert AppriseConfig.instantiate( 'file://?', suppress_exceptions=True) is None assert AppriseConfig.instantiate( 'invalid://?', suppress_exceptions=True) is None class BadConfig(ConfigBase): def __init__(self, **kwargs): super(BadConfig, self).__init__(**kwargs) # We fail whenever we're initialized raise TypeError() # Store our bad configuration in our schema map CONFIG_SCHEMA_MAP['bad'] = BadConfig with pytest.raises(TypeError): AppriseConfig.instantiate( 'bad://path', suppress_exceptions=False) # Same call but exceptions suppressed assert AppriseConfig.instantiate( 'bad://path', suppress_exceptions=True) is None
def test_apprise_instantiate(): """ API: AppriseConfig.instantiate() """ assert AppriseConfig.instantiate('file://?', suppress_exceptions=True) is None assert AppriseConfig.instantiate('invalid://?', suppress_exceptions=True) is None class BadConfig(ConfigBase): def __init__(self, **kwargs): super(BadConfig, self).__init__(**kwargs) # We fail whenever we're initialized raise TypeError() # Store our bad configuration in our schema map CONFIG_SCHEMA_MAP['bad'] = BadConfig try: AppriseConfig.instantiate('bad://path', suppress_exceptions=False) # We should never make it to this line assert False except TypeError: # Exception caught as expected assert True # Same call but exceptions suppressed assert AppriseConfig.instantiate('bad://path', suppress_exceptions=True) is None