Skip to content

Commit

Permalink
Merge pull request #25 from 4Catalyzer/check-path
Browse files Browse the repository at this point in the history
Check FileAnnex root_path
  • Loading branch information
taion authored Sep 16, 2016
2 parents 1e47aa9 + a9dedf3 commit df01927
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions flask_annex/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

class FileAnnex(AnnexBase):
def __init__(self, root_path):
if not os.path.exists(root_path):
raise IOError("root path {} does not exist".format(root_path))

self._root_path = root_path

def _get_filename(self, key):
Expand Down
10 changes: 9 additions & 1 deletion tests/test_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

@pytest.fixture
def file_annex_path(tmpdir):
return tmpdir.join('annex').strpath
return tmpdir.join('annex').mkdir().strpath


# -----------------------------------------------------------------------------
Expand Down Expand Up @@ -41,3 +41,11 @@ def annex_base(self, monkeypatch, file_annex_path):
monkeypatch.setenv('FLASK_ANNEX_FILE_ROOT_PATH', file_annex_path)

return Annex.from_env('FLASK_ANNEX')


# -----------------------------------------------------------------------------


def test_error_nonexistent_root_path():
with pytest.raises(IOError):
Annex('file', root_path='/dummy')

0 comments on commit df01927

Please sign in to comment.