Beispiel #1
0
def test_validate_cachito_config_failure(mock_isdir, app, variable_name):
    expected = f'The configuration "{variable_name}" must be set'
    if variable_name == "CACHITO_BUNDLES_DIR":
        expected += " to an existing directory"
    with patch.dict(app.config, {variable_name: None}):
        with pytest.raises(ConfigError, match=expected):
            validate_cachito_config(app.config)
Beispiel #2
0
def create_cli_app():
    """
    Create a Flask application instance and validate the configuration for the Flask CLI.

    :return: a Flask application object
    :rtype: flask.Flask
    """
    app = create_app()
    validate_cachito_config(app.config, cli=True)
    return app
Beispiel #3
0
def test_validate_mutually_exclusive_package_managers(app, value, is_valid):
    config = app.config.copy()
    config["CACHITO_MUTUALLY_EXCLUSIVE_PACKAGE_MANAGERS"] = value

    if is_valid:
        validate_cachito_config(config)
    else:
        expected = (
            r'All values in "CACHITO_MUTUALLY_EXCLUSIVE_PACKAGE_MANAGERS" '
            r"must be pairs \(2-tuples or 2-item lists\)")
        with pytest.raises(ConfigError, match=expected):
            validate_cachito_config(config)
Beispiel #4
0
def test_validate_mutually_exclusive_package_managers(app, value, is_valid, tmpdir):
    config = app.config.copy()
    config["CACHITO_MUTUALLY_EXCLUSIVE_PACKAGE_MANAGERS"] = value

    if is_valid:
        # Successful validation requires this dir exists.
        config["CACHITO_BUNDLES_DIR"] = str(tmpdir)
        validate_cachito_config(config)
    else:
        expected = (
            r'All values in "CACHITO_MUTUALLY_EXCLUSIVE_PACKAGE_MANAGERS" '
            r"must be pairs \(2-tuples or 2-item lists\)"
        )
        with pytest.raises(ConfigError, match=expected):
            validate_cachito_config(config)
Beispiel #5
0
# SPDX-License-Identifier: GPL-3.0-or-later
from cachito.web.app import create_app
from cachito.web.config import validate_cachito_config

app = create_app()
validate_cachito_config(app.config)
Beispiel #6
0
def test_validate_cachito_config_cli(mock_isdir, app):
    validate_cachito_config(app.config, cli=True)
    mock_isdir.assert_not_called()
Beispiel #7
0
def test_validate_cachito_config_success(mock_isdir, app):
    validate_cachito_config(app.config)
    mock_isdir.assert_any_call(os.path.join(tempfile.gettempdir(), "cachito-archives/bundles"))
def test_validate_cachito_config_success(mock_isdir, app):
    validate_cachito_config(app.config)
    mock_isdir.assert_any_call('/tmp/cachito-archives/bundles')