Mercurial > kallithea
changeset 873:386fe4ce5f97 beta
Added tests for archival, cleaned changelog test from prints
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Tue, 21 Dec 2010 02:02:27 +0100 |
parents | b956e6f415a2 |
children | 4bace4aada09 |
files | rhodecode/tests/functional/test_changelog.py rhodecode/tests/functional/test_files.py |
diffstat | 2 files changed, 51 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/rhodecode/tests/functional/test_changelog.py Tue Dec 21 01:11:38 2010 +0100 +++ b/rhodecode/tests/functional/test_changelog.py Tue Dec 21 02:02:27 2010 +0100 @@ -6,7 +6,6 @@ self.log_user() response = self.app.get(url(controller='changelog', action='index', repo_name=HG_REPO)) - print response.body assert """<div id="chg_20" class="container">""" in response.body, 'wrong info about number of changes' assert """<div class="date">commit 154: 5e204e7583b9@2010-08-10 01:18:46</div>""" in response.body , 'no info on this commit' assert """Small update at simplevcs app""" in response.body, 'missing info about commit message' @@ -24,7 +23,6 @@ response = self.app.get(url(controller='changelog', action='index', repo_name=HG_REPO), {'page':6}) # Test response after pagination... - print response.body assert """<div class="date">commit 64: 46ad32a4f974@2010-04-20 00:33:21</div>"""in response.body, 'wrong info about commit 64' assert """<span class="removed tooltip" tooltip_title="removed: docs/api.rst">1</span>"""in response.body, 'wrong info about number of removed' assert """<span class="changed tooltip" tooltip_title="changed: .hgignore<br/> README.rst<br/> docs/conf.py<br/> docs/index.rst<br/> setup.py<br/> tests/test_hg.py<br/> tests/test_nodes.py<br/> vcs/__init__.py<br/> vcs/backends/__init__.py<br/> vcs/backends/base.py<br/> vcs/backends/hg.py<br/> vcs/nodes.py<br/> vcs/utils/__init__.py">13</span>"""in response.body, 'wrong info about number of changes'
--- a/rhodecode/tests/functional/test_files.py Tue Dec 21 01:11:38 2010 +0100 +++ b/rhodecode/tests/functional/test_files.py Tue Dec 21 02:02:27 2010 +0100 @@ -1,5 +1,11 @@ from rhodecode.tests import * +ARCHIVE_SPECS = { + '.tar.bz2': ('application/x-tar', 'tbz2', ''), + '.tar.gz': ('application/x-tar', 'tgz', ''), + '.zip': ('application/zip', 'zip', ''), +} + class TestFilesController(TestController): def test_index(self): @@ -188,3 +194,48 @@ </optgroup>""" in response.body, 'missing or wrong history in annotation' assert """<span style="text-transform: uppercase;"><a href="#">branch: default</a></span>""" in response.body, 'missing or wrong branch info' + + + + def test_archival(self): + self.log_user() + + for arch_ext, info in ARCHIVE_SPECS.items(): + fname = '27cd5cce30c96924232dffcd24178a07ffeb5dfc%s' % arch_ext + filename = '%s-%s' % (HG_REPO, fname) + + response = self.app.get(url(controller='files', action='archivefile', + repo_name=HG_REPO, + fname=fname)) + + assert response.status == '200 OK', 'wrong response code' + assert response.response._headers.items() == [('Pragma', 'no-cache'), + ('Cache-Control', 'no-cache'), + ('Content-Type', '%s; charset=utf-8' % info[0]), + ('Content-Disposition', 'attachment; filename=%s' % filename), ], 'wrong headers' + + def test_archival_wrong_ext(self): + self.log_user() + + for arch_ext in ['tar', 'rar', 'x', '..ax', '.zipz']: + fname = '27cd5cce30c96924232dffcd24178a07ffeb5dfc%s' % arch_ext + + response = self.app.get(url(controller='files', action='archivefile', + repo_name=HG_REPO, + fname=fname)) + assert 'Unknown archive type' in response.body + + + def test_archival_wrong_revision(self): + self.log_user() + + for rev in ['00x000000', 'tar', 'wrong', '@##$@$424213232', '232dffcd']: + fname = '%s.zip' % rev + + response = self.app.get(url(controller='files', action='archivefile', + repo_name=HG_REPO, + fname=fname)) + assert 'Unknown revision' in response.body + + +