def test_load_bad_permissions_file():
    """Should raise exception if file permissions prevent it from being read"""
    with NamedTemporaryFile() as f:
        fixture_file = f.name
        chmod(fixture_file, 0)

        with pytest.raises(etcsettings.FileCanNotBeRead):
            etcsettings.load(fixture_file)
def test_load_bad_syntax():
    """Should raise exception if file syntax is not as YAML as it should"""
    fixture_file = _file_here('test_settings.ini')

    with pytest.raises(etcsettings.FileIsNotYaml):
        etcsettings.load(fixture_file)
def test_load_no_file():
    """Should raise exception if file does not exist"""
    fixture_file = _file_here('not-a-file-at-all')

    with pytest.raises(etcsettings.FileDoesNotExist):
        etcsettings.load(fixture_file)
def test_load():
    """Should load settings by file name"""
    settings = etcsettings.load(FIXTURE_FILE)
    assert settings == _load_yaml(FIXTURE_FILE)