Пример #1
0
def test_001(settings, custom_project_settings):
    """
    Ensure cleaning dont drop anything
    """
    backend = SettingsBackendBase(basedir=settings.fixtures_path)

    assert backend.clean(custom_project_settings) == custom_project_settings
Пример #2
0
def test_ok_002(settings):
    """conf.base_backendSettingsBackendBase: Filepath check case 2"""
    backend = SettingsBackendBase()

    result = backend.check_filepath(settings.sample_path, filename="dummy")

    assert result == os.path.join(settings.sample_path, "dummy")
Пример #3
0
def test_ok_002(settings):
    """conf.base_backendSettingsBackendBase: Filepath check case 2"""
    backend = SettingsBackendBase()

    result = backend.check_filepath(settings.sample_path, filename="dummy")

    assert result == os.path.join(settings.sample_path, "dummy")
Пример #4
0
def test_ok_001(settings):
    """conf.base_backendSettingsBackendBase: Filepath check case 1"""
    backend = SettingsBackendBase()

    result = backend.check_filepath(settings.fixtures_path, filename=SettingsBackendBase._default_filename)

    assert result == os.path.join(settings.fixtures_path, SettingsBackendBase._default_filename)
Пример #5
0
def test_ok_001(settings):
    """conf.base_backend.SettingsBackendBase: Open given filepath"""
    backend = SettingsBackendBase(basedir=settings.fixtures_path)

    path, filename = backend.parse_filepath()
    filepath = backend.check_filepath(path, filename)

    assert backend.open(filepath) == """Fake settings file as SettingsBackendBase dont implement a full usable interface."""
Пример #6
0
def test_error_001(settings):
    """
    conf.base_backendSettingsBackendBase: Filepath check error case 1
    (dont exist)
    """
    backend = SettingsBackendBase()

    with pytest.raises(SettingsBackendError):
        backend.check_filepath(settings.fixtures_path, filename="dontexists")
Пример #7
0
def test_ok_001(settings):
    """conf.base_backendSettingsBackendBase: Filepath check case 1"""
    backend = SettingsBackendBase()

    result = backend.check_filepath(
        settings.fixtures_path, filename=SettingsBackendBase._default_filename)

    assert result == os.path.join(settings.fixtures_path,
                                  SettingsBackendBase._default_filename)
Пример #8
0
def test_error_002(settings):
    """
    conf.base_backendSettingsBackendBase: Filepath check error case 2
    (filename is a dir)
    """
    backend = SettingsBackendBase()

    with pytest.raises(SettingsBackendError):
        backend.check_filepath(settings.sample_path, filename="components")
Пример #9
0
def test_002_empty_basedir(settings, sample_project_settings):
    """
    no path given and with a basedir
    """
    backend = SettingsBackendBase(basedir="/home/bart/www")

    result = backend.parse_filepath()

    assert result == ("/home/bart/www", "settings.txt")
Пример #10
0
def test_001_empty_nobasedir(settings, sample_project_settings):
    """
    no path given and with empty basedir
    """
    backend = SettingsBackendBase()

    result = backend.parse_filepath()

    assert result == ('.', "settings.txt")
Пример #11
0
def test_001_empty_nobasedir(settings, sample_project_settings):
    """no path given and with empty basedir"""
    backend = SettingsBackendBase()

    result = backend.parse_filepath()

    assert result == (
        '.',
        "settings.txt"
    )
Пример #12
0
def test_009_normalize_02_basedir(settings, sample_project_settings):
    """filename and filled basedir, need normalize"""
    backend = SettingsBackendBase(basedir="/home/bart/www")

    result = backend.parse_filepath(filepath="../settings_custom.txt")

    assert result == (
        '/home/bart',
        "settings_custom.txt",
    )
Пример #13
0
def test_002_empty_basedir(settings, sample_project_settings):
    """no path given and with a basedir"""
    backend = SettingsBackendBase(basedir="/home/bart/www")

    result = backend.parse_filepath()

    assert result == (
        "/home/bart/www",
        "settings.txt"
    )
Пример #14
0
def test_011_normalize_nobasedir(settings, sample_project_settings):
    """filename and empty basedir, normalize can't do anything"""
    backend = SettingsBackendBase()

    result = backend.parse_filepath(filepath="../settings_custom.txt")

    assert result == (
        '..',
        "settings_custom.txt",
    )
Пример #15
0
def test_007_absolute_nobasedir(settings, sample_project_settings):
    """absolute filepath and empty basedir"""
    backend = SettingsBackendBase()

    result = backend.parse_filepath(filepath="/home/bart/www/settings_custom.txt")

    assert result == (
        "/home/bart/www",
        "settings_custom.txt",
    )
Пример #16
0
def test_003_filename_nobasedir(settings, sample_project_settings):
    """filename and empty basedir"""
    backend = SettingsBackendBase()

    result = backend.parse_filepath(filepath="settings_custom.txt")

    assert result == (
        '.',
        "settings_custom.txt",
    )
Пример #17
0
def test_006_relative_basedir(settings, sample_project_settings):
    """relative filepath and filled basedir"""
    backend = SettingsBackendBase(basedir="/home/bart/www")

    result = backend.parse_filepath(filepath="foo/settings_custom.txt")

    assert result == (
        "/home/bart/www/foo",
        "settings_custom.txt",
    )
Пример #18
0
def test_005_relative_nobasedir(settings, sample_project_settings):
    """relative filepath and empty basedir"""
    backend = SettingsBackendBase()

    result = backend.parse_filepath(filepath="foo/settings_custom.txt")

    assert result == (
        'foo',
        "settings_custom.txt",
    )
Пример #19
0
def test_004_filename_basedir(settings, sample_project_settings):
    """filename and filled basedir"""
    backend = SettingsBackendBase(basedir="/home/bart/www")

    result = backend.parse_filepath(filepath="settings_custom.txt")

    assert result == (
        '/home/bart/www',
        "settings_custom.txt",
    )
Пример #20
0
def test_ok_001(settings):
    """conf.base_backend.SettingsBackendBase: Open given filepath"""
    backend = SettingsBackendBase(basedir=settings.fixtures_path)

    path, filename = backend.parse_filepath()
    filepath = backend.check_filepath(path, filename)

    assert backend.open(
        filepath
    ) == """Fake settings file as SettingsBackendBase dont implement a full usable interface."""
Пример #21
0
def test_008_absolute_basedir(settings, sample_project_settings):
    """absolute filepath and filled basedir to ensure basedir is ignored with
       absolute filepath"""
    backend = SettingsBackendBase(basedir="/home/no/pasaran")

    result = backend.parse_filepath(filepath="/home/bart/www/settings_custom.txt")

    assert result == (
        "/home/bart/www",
        "settings_custom.txt",
    )
Пример #22
0
def test_ok_001(settings):
    """conf.base_backend.SettingsBackendBase: Dummy content parsing"""
    backend = SettingsBackendBase(basedir=settings.fixtures_path)

    path, filename = backend.parse_filepath()
    filepath = backend.check_filepath(path, filename)

    content = backend.open(filepath)

    assert backend.parse(filepath, content) == {}
Пример #23
0
def test_001(settings, custom_project_settings):
    """conf.base_backend.SettingsBackendBase: Ensure cleaning dont drop anything"""
    backend = SettingsBackendBase(basedir=settings.fixtures_path)

    assert backend.clean(custom_project_settings) == custom_project_settings
Пример #24
0
def test_error_001(settings):
    """conf.base_backendSettingsBackendBase: Filepath check error case 1 (dont exist)"""
    backend = SettingsBackendBase()

    with pytest.raises(SettingsBackendError):
        backend.check_filepath(settings.fixtures_path, filename="dontexists")
Пример #25
0
def test_error_002(settings):
    """conf.base_backendSettingsBackendBase: Filepath check error case 2 (filename is a dir)"""
    backend = SettingsBackendBase()

    with pytest.raises(SettingsBackendError):
        backend.check_filepath(settings.sample_path, filename="components")