def sams_config_is_valid():
    """Check if config is valid and should be only run once per load. Returns client obj used to acces SAM API"""
    if config_valid():
        return Client(CONFIG_BROKER['sam']['wsdl'])
    else:
        logger.error({
            'message': "Invalid SAM wsdl config",
            'message_type': 'CoreError'
        })
        sys.exit(1)
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 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_empty(monkeypatch):
    monkeypatch.setattr(fileE, 'CONFIG_BROKER', {})
    assert not fileE.config_valid()
def test_config_valid_password_none(monkeypatch):
    config = deepcopy(_VALID_CONFIG)
    config['sam']['password'] = None
    monkeypatch.setattr(fileE, 'CONFIG_BROKER', config)
    assert not fileE.config_valid()
def test_config_valid_empty_username(monkeypatch):
    config = deepcopy(_VALID_CONFIG)
    config['sam']['username'] = ''
    monkeypatch.setattr(fileE, 'CONFIG_BROKER', config)
    assert not fileE.config_valid()
def test_config_valid_missing_wsdl(monkeypatch):
    config = deepcopy(_VALID_CONFIG)
    del config['sam']['wsdl']
    monkeypatch.setattr(fileE, 'CONFIG_BROKER', config)
    assert not fileE.config_valid()
def test_config_valid_complete(monkeypatch):
    monkeypatch.setattr(fileE, 'CONFIG_BROKER', _VALID_CONFIG)
    assert fileE.config_valid()