Mercurial > hatta-flask
changeset 2391:f9e818a159d0
Fix #43: Moved to in-memory commits. Updated the tests.
The tests checking for symlinks and directories have been removed, as they
are now irrelevant, because Hatta no longer touches the filesystem directly.
All the tests that check for files now need an ``hg update`` command, to
make the changes actually appear in the working directory.
| author | Radomir Dopieralski <sheep-devel@sheep.art.pl> |
|---|---|
| date | Sun, 12 May 2013 11:52:05 +0200 |
| parents | 428b3e89a6e8 |
| children | 6bd10c46c14a |
| files | hatta/storage.py tests/test_repo.py |
| diffstat | 2 files changed, 20 insertions(+), 81 deletions(-) [+] |
line wrap: on
line diff
--- a/hatta/storage.py Sun May 12 11:11:48 2013 +0200 +++ b/hatta/storage.py Sun May 12 11:52:05 2013 +0200 @@ -466,7 +466,7 @@ parent, other = self._get_parents(repo_file, parent_rev) if data is None: if title not in self: - raise error.ForbiddenErr() + raise error.NotFoundErr() else: if other is not None: try:
--- a/tests/test_repo.py Sun May 12 11:11:48 2013 +0200 +++ b/tests/test_repo.py Sun May 12 11:52:05 2013 +0200 @@ -8,12 +8,10 @@ """ import os -import sys import hatta -import py import py.test -import werkzeug +import mercurial.commands # Patch for no gettext hatta._ = lambda x:x @@ -59,7 +57,11 @@ request.addfinalizer(lambda: clear_directory(repo_path)) return hatta.storage.WikiSubdirectoryStorage(repo_path) -@py.test.mark.skipif('True') + +def update(storage): + mercurial.commands.update(storage.repo.ui, storage.repo) + + class TestSubdirectoryStorage(object): """ Tests for the WikiSubdirectoryStorage. @@ -100,6 +102,7 @@ filepath = os.path.join(subdir_repo.path, filename) subdir_repo.save_text(title, self.text, self.author, self.comment, parent=-1) + update(subdir_repo) exists = os.path.exists(filepath) assert exists @@ -114,6 +117,7 @@ subdir_repo.save_text(title, self.text, self.author, self.comment, parent=-1) subdir_repo.delete_page(title, self.author, self.comment) + update(subdir_repo) exists = os.path.exists(filepath) assert not exists exists = os.path.exists(dirpath) @@ -128,9 +132,11 @@ filepath = os.path.join(subdir_repo.path, 'ziew') subdir_repo.save_text(title, self.text, self.author, self.comment, parent=-1) + update(subdir_repo) exists = os.path.exists(filepath) assert exists subdir_repo.delete_page(title, self.author, self.comment) + update(subdir_repo) exists = os.path.exists(filepath) assert not exists @@ -141,11 +147,11 @@ title = u'ziew2' filepath = os.path.join(subdir_repo.path, 'ziew2') - exists = os.path.exists(filepath) - assert not exists - subdir_repo.delete_page(title, self.author, self.comment) - exists = os.path.exists(filepath) - assert not exists + assert not os.path.exists(filepath) + with py.test.raises(hatta.error.NotFoundErr): + subdir_repo.delete_page(title, self.author, self.comment) + update(subdir_repo) + assert not os.path.exists(filepath) def test_create_parent(self, subdir_repo): """ @@ -156,6 +162,7 @@ parent=-1) subdir_repo.save_text(u'xxx', self.text, self.author, self.comment, parent=-1) + update(subdir_repo) assert os.path.exists(os.path.join(subdir_repo.path, 'xxx')) assert os.path.exists(os.path.join(subdir_repo.path, 'xxx/yyy')) assert os.path.exists(os.path.join(subdir_repo.path, 'xxx/Index')) @@ -169,6 +176,7 @@ parent=-1) subdir_repo.save_text(u'xxx/yyy', self.text, self.author, self.comment, parent=-1) + update(subdir_repo) assert os.path.exists(os.path.join(subdir_repo.path, 'xxx')) assert os.path.exists(os.path.join(subdir_repo.path, 'xxx/yyy')) assert os.path.exists(os.path.join(subdir_repo.path, 'xxx/Index')) @@ -184,6 +192,7 @@ parent=-1) subdir_repo.save_text(u'xxx/yyy/zzz', self.text, self.author, self.comment, parent=-1) + update(subdir_repo) assert os.path.exists(os.path.join(subdir_repo.path, 'xxx')) assert os.path.exists(os.path.join(subdir_repo.path, 'xxx/yyy')) assert not os.path.exists(os.path.join(subdir_repo.path, 'xxx/yyy/Index')) @@ -201,7 +210,6 @@ text = u'test text' comment = u'test comment' - @py.test.mark.skipif('True') def test_filename(self, repo): """ Check if the page's file is named properly. @@ -221,46 +229,11 @@ filepath = os.path.join(repo.path, filename) repo.save_text(title, self.text, self.author, self.comment, parent=-1) + update(repo) exists = os.path.exists(filepath) print '%s -> %s' % (repr(title), filename) assert exists - def test_check_path(self, repo): - py.test.raises(hatta.error.ForbiddenErr, repo._check_path, "/") - py.test.raises(hatta.error.ForbiddenErr, repo._check_path, "..") - py.test.raises(hatta.error.ForbiddenErr, repo._check_path, - repo.path+"/..") - path = os.path.join(repo.path, 'aaa') - os.symlink('/', path) - py.test.raises(hatta.error.ForbiddenErr, repo._check_path, path) - path = os.path.join(repo.path, 'bbb') - os.mkdir(path) - py.test.raises(hatta.error.ForbiddenErr, repo._check_path, path) - - @py.test.mark.skipif('True') - @py.test.mark.skipif("sys.platform == 'win32'") - def test_symlinks(self, repo): - """ - Make sure access to symlinks is blocked. - """ - - path = os.path.join(repo.path, self.filename) - os.symlink('/', path) - py.test.raises(hatta.error.ForbiddenErr, repo.save_text, - self.title, self.text, self.author, self.comment, - parent=-1) - py.test.raises(hatta.error.ForbiddenErr, repo.open_page, - self.title) - - @py.test.mark.skipif("sys.platform == 'win32'") - def test_symlinks_not_exist(self, repo): - """ - Make sure symlinks are not reported as existing pages. - """ - - path = os.path.join(repo.path, self.filename) - os.symlink('/', path) - assert self.title not in repo def test_directories_not_exist(self, repo): """ @@ -281,40 +254,6 @@ py.test.raises(hatta.error.NotFoundErr, repo.open_page, self.title) - @py.test.mark.skipif('True') - def test_directory_write(self, repo): - """ - What happens when you try to write a directory as page. - """ - - path = os.path.join(repo.path, self.filename) - os.mkdir(path) - py.test.raises(hatta.error.ForbiddenErr, repo.save_text, - self.title, self.text, self.author, self.comment, - parent=-1) - - @py.test.mark.skipif('True') - def test_directory_delete(self, repo): - """ - What happens when you try to delete a directory as page. - """ - - path = os.path.join(repo.path, self.filename) - os.mkdir(path) - py.test.raises(hatta.error.ForbiddenErr, repo.delete_page, - self.title, self.author, self.comment) - - @py.test.mark.skipif("sys.platform == 'win32'") - def test_symlink_delete(self, repo): - """ - What happens when you try to delete a symlink as page. - """ - - path = os.path.join(repo.path, self.filename) - os.symlink('/', path) - py.test.raises(hatta.error.ForbiddenErr, repo.delete_page, - self.title, self.author, self.comment) - class TestStorage(object): """
