def test_get_valid_rw_apikey(): with patch.object(ConfigParser.ConfigParser, 'get', return_value=ID_WITH_VALID_LENGTH): rw_api_key = api_utils.get_rw_apikey() assert rw_api_key == ID_WITH_VALID_LENGTH
def test_get_invalid_rw_apikey(capsys): with patch.object(ConfigParser.ConfigParser, 'get', return_value=ID_WITH_INVALID_LENGTH): with pytest.raises(SystemExit): api_utils.load_config = Mock() result = api_utils.get_rw_apikey() out, err = capsys.readouterr() assert result is None assert ID_WITH_INVALID_LENGTH in out assert 'is not of correct length' in out