def sam_config_is_valid(): """ Check if config is valid and should be only run once per load. Returns client obj used to acces SAM API. Returns: client object representing the SAM service """ if config_valid(): return get_client() else: logger.error({ 'message': "Invalid SAM wsdl config", 'message_type': 'CoreError' }) sys.exit(1)
def test_config_valid_password_none(monkeypatch): config = deepcopy(_VALID_CONFIG) config['sam']['password'] = None monkeypatch.setattr(sam_wsdl_helper, 'CONFIG_BROKER', config) assert not sam_wsdl_helper.config_valid()
def test_config_valid_empty_username(monkeypatch): config = deepcopy(_VALID_CONFIG) config['sam']['username'] = '' monkeypatch.setattr(sam_wsdl_helper, 'CONFIG_BROKER', config) assert not sam_wsdl_helper.config_valid()
def test_config_valid_missing_wsdl(monkeypatch): config = deepcopy(_VALID_CONFIG) del config['sam']['wsdl'] monkeypatch.setattr(sam_wsdl_helper, 'CONFIG_BROKER', config) assert not sam_wsdl_helper.config_valid()
def test_config_valid_complete(monkeypatch): monkeypatch.setattr(sam_wsdl_helper, 'CONFIG_BROKER', _VALID_CONFIG) assert sam_wsdl_helper.config_valid()
def test_config_valid_empty(monkeypatch): monkeypatch.setattr(sam_wsdl_helper, 'CONFIG_BROKER', {}) assert not sam_wsdl_helper.config_valid()