test_files.py
743 lines
| 33.8 KiB
| text/x-python
|
PythonLexer
Bradley M. Kuhn
|
r4116 | # -*- coding: utf-8 -*- | ||
r3839 | import os | |||
r547 | from rhodecode.tests import * | |||
r3056 | from rhodecode.model.db import Repository | |||
from rhodecode.model.meta import Session | ||||
r3839 | from rhodecode.tests.fixture import Fixture | |||
fixture = Fixture() | ||||
r547 | ||||
r873 | ARCHIVE_SPECS = { | |||
r951 | '.tar.bz2': ('application/x-bzip2', 'tbz2', ''), | |||
'.tar.gz': ('application/x-gzip', 'tgz', ''), | ||||
r873 | '.zip': ('application/zip', 'zip', ''), | |||
} | ||||
Bradley M. Kuhn
|
r4116 | HG_NODE_HISTORY = fixture.load_resource('hg_node_history_response.json') | ||
GIT_NODE_HISTORY = fixture.load_resource('git_node_history_response.json') | ||||
r1984 | ||||
r3056 | def _set_downloads(repo_name, set_to): | |||
repo = Repository.get_by_repo_name(repo_name) | ||||
repo.enable_downloads = set_to | ||||
Session().add(repo) | ||||
Session().commit() | ||||
r547 | class TestFilesController(TestController): | |||
def test_index(self): | ||||
self.log_user() | ||||
response = self.app.get(url(controller='files', action='index', | ||||
r688 | repo_name=HG_REPO, | |||
r547 | revision='tip', | |||
f_path='/')) | ||||
# Test response... | ||||
r3797 | response.mustcontain('<a class="browser-dir ypjax-link" href="/vcs_test_hg/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/docs">docs</a>') | |||
response.mustcontain('<a class="browser-dir ypjax-link" href="/vcs_test_hg/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/vcs">vcs</a>') | ||||
response.mustcontain('<a class="browser-file ypjax-link" href="/vcs_test_hg/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/.gitignore">.gitignore</a>') | ||||
response.mustcontain('<a class="browser-file ypjax-link" href="/vcs_test_hg/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/.hgignore">.hgignore</a>') | ||||
response.mustcontain('<a class="browser-file ypjax-link" href="/vcs_test_hg/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/.hgtags">.hgtags</a>') | ||||
response.mustcontain('<a class="browser-file ypjax-link" href="/vcs_test_hg/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/.travis.yml">.travis.yml</a>') | ||||
response.mustcontain('<a class="browser-file ypjax-link" href="/vcs_test_hg/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/MANIFEST.in">MANIFEST.in</a>') | ||||
response.mustcontain('<a class="browser-file ypjax-link" href="/vcs_test_hg/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/README.rst">README.rst</a>') | ||||
response.mustcontain('<a class="browser-file ypjax-link" href="/vcs_test_hg/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/run_test_and_report.sh">run_test_and_report.sh</a>') | ||||
response.mustcontain('<a class="browser-file ypjax-link" href="/vcs_test_hg/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/setup.cfg">setup.cfg</a>') | ||||
response.mustcontain('<a class="browser-file ypjax-link" href="/vcs_test_hg/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/setup.py">setup.py</a>') | ||||
response.mustcontain('<a class="browser-file ypjax-link" href="/vcs_test_hg/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/test_and_report.sh">test_and_report.sh</a>') | ||||
response.mustcontain('<a class="browser-file ypjax-link" href="/vcs_test_hg/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/tox.ini">tox.ini</a>') | ||||
r729 | ||||
def test_index_revision(self): | ||||
self.log_user() | ||||
r1984 | response = self.app.get( | |||
url(controller='files', action='index', | ||||
repo_name=HG_REPO, | ||||
revision='7ba66bec8d6dbba14a2155be32408c435c5f4492', | ||||
f_path='/') | ||||
) | ||||
r729 | ||||
#Test response... | ||||
r1984 | response.mustcontain('<a class="browser-dir ypjax-link" href="/vcs_test_hg/files/7ba66bec8d6dbba14a2155be32408c435c5f4492/docs">docs</a>') | |||
response.mustcontain('<a class="browser-dir ypjax-link" href="/vcs_test_hg/files/7ba66bec8d6dbba14a2155be32408c435c5f4492/tests">tests</a>') | ||||
response.mustcontain('<a class="browser-file ypjax-link" href="/vcs_test_hg/files/7ba66bec8d6dbba14a2155be32408c435c5f4492/README.rst">README.rst</a>') | ||||
response.mustcontain('1.1 KiB') | ||||
response.mustcontain('text/x-python') | ||||
r729 | ||||
def test_index_different_branch(self): | ||||
self.log_user() | ||||
response = self.app.get(url(controller='files', action='index', | ||||
repo_name=HG_REPO, | ||||
revision='97e8b885c04894463c51898e14387d80c30ed1ee', | ||||
f_path='/')) | ||||
Mads Kiilerich
|
r3654 | response.mustcontain("""<span style="text-transform: uppercase;"><a href="#">Branch: git</a></span>""") | ||
r729 | ||||
def test_index_paging(self): | ||||
self.log_user() | ||||
for r in [(73, 'a066b25d5df7016b45a41b7e2a78c33b57adc235'), | ||||
(92, 'cc66b61b8455b264a7a8a2d8ddc80fcfc58c221e'), | ||||
(109, '75feb4c33e81186c87eac740cee2447330288412'), | ||||
(1, '3d8f361e72ab303da48d799ff1ac40d5ac37c67e'), | ||||
(0, 'b986218ba1c9b0d6a259fac9b050b1724ed8e545')]: | ||||
response = self.app.get(url(controller='files', action='index', | ||||
repo_name=HG_REPO, | ||||
revision=r[1], | ||||
f_path='/')) | ||||
r1984 | response.mustcontain("""@ r%s:%s""" % (r[0], r[1][:12])) | |||
r729 | ||||
def test_file_source(self): | ||||
self.log_user() | ||||
response = self.app.get(url(controller='files', action='index', | ||||
repo_name=HG_REPO, | ||||
r3797 | revision='8911406ad776fdd3d0b9932a2e89677e57405a48', | |||
r729 | f_path='vcs/nodes.py')) | |||
r3009 | response.mustcontain("""<div class="commit">Partially implemented <a class="issue-tracker-link" href="https://myissueserver.com/vcs_test_hg/issue/16">#16</a>. filecontent/commit message/author/node name are safe_unicode now. | |||
In addition some other __str__ are unicode as well | ||||
Added test for unicode | ||||
Improved test to clone into uniq repository. | ||||
removed extra unicode conversion in diff.</div> | ||||
""") | ||||
Mads Kiilerich
|
r3654 | response.mustcontain("""<span style="text-transform: uppercase;"><a href="#">Branch: default</a></span>""") | ||
r3009 | ||||
def test_file_source_history(self): | ||||
self.log_user() | ||||
response = self.app.get(url(controller='files', action='history', | ||||
repo_name=HG_REPO, | ||||
Bradley M. Kuhn
|
r4116 | revision='tip', | ||
r3009 | f_path='vcs/nodes.py'), | |||
extra_environ={'HTTP_X_PARTIAL_XHR': '1'},) | ||||
Bradley M. Kuhn
|
r4116 | self.assertEqual(response.body, HG_NODE_HISTORY) | ||
def test_file_source_history_git(self): | ||||
self.log_user() | ||||
response = self.app.get(url(controller='files', action='history', | ||||
repo_name=GIT_REPO, | ||||
revision='master', | ||||
f_path='vcs/nodes.py'), | ||||
extra_environ={'HTTP_X_PARTIAL_XHR': '1'},) | ||||
self.assertEqual(response.body, GIT_NODE_HISTORY) | ||||
r729 | ||||
def test_file_annotation(self): | ||||
self.log_user() | ||||
r2180 | response = self.app.get(url(controller='files', action='index', | |||
r729 | repo_name=HG_REPO, | |||
Bradley M. Kuhn
|
r4116 | revision='tip', | ||
r2180 | f_path='vcs/nodes.py', | |||
annotate=True)) | ||||
r729 | ||||
Bradley M. Kuhn
|
r4116 | response.mustcontain("""r356:25213a5fbb04""") | ||
r729 | ||||
r2451 | def test_file_annotation_git(self): | |||
self.log_user() | ||||
response = self.app.get(url(controller='files', action='index', | ||||
repo_name=GIT_REPO, | ||||
revision='master', | ||||
f_path='vcs/nodes.py', | ||||
annotate=True)) | ||||
Bradley M. Kuhn
|
r4116 | response.mustcontain("""r345:c994f0de03b2""") | ||
def test_file_annotation_history(self): | ||||
self.log_user() | ||||
response = self.app.get(url(controller='files', action='history', | ||||
repo_name=HG_REPO, | ||||
revision='tip', | ||||
f_path='vcs/nodes.py', | ||||
annotate=True), | ||||
extra_environ={'HTTP_X_PARTIAL_XHR': '1'}) | ||||
self.assertEqual(response.body, HG_NODE_HISTORY) | ||||
def test_file_annotation_history_git(self): | ||||
self.log_user() | ||||
response = self.app.get(url(controller='files', action='history', | ||||
repo_name=GIT_REPO, | ||||
revision='master', | ||||
f_path='vcs/nodes.py', | ||||
annotate=True), | ||||
extra_environ={'HTTP_X_PARTIAL_XHR': '1'}) | ||||
self.assertEqual(response.body, GIT_NODE_HISTORY) | ||||
def test_file_authors(self): | ||||
self.log_user() | ||||
response = self.app.get(url(controller='files', action='authors', | ||||
repo_name=HG_REPO, | ||||
revision='tip', | ||||
f_path='vcs/nodes.py', | ||||
annotate=True)) | ||||
response.mustcontain('Marcin Kuzminski') | ||||
response.mustcontain('Lukasz Balcerzak') | ||||
def test_file_authors_git(self): | ||||
self.log_user() | ||||
response = self.app.get(url(controller='files', action='authors', | ||||
repo_name=GIT_REPO, | ||||
revision='master', | ||||
f_path='vcs/nodes.py', | ||||
annotate=True)) | ||||
response.mustcontain('Marcin Kuzminski') | ||||
response.mustcontain('Lukasz Balcerzak') | ||||
r2451 | ||||
r873 | def test_archival(self): | |||
self.log_user() | ||||
r3056 | _set_downloads(HG_REPO, set_to=True) | |||
r873 | for arch_ext, info in ARCHIVE_SPECS.items(): | |||
r2277 | short = '27cd5cce30c9%s' % arch_ext | |||
r873 | fname = '27cd5cce30c96924232dffcd24178a07ffeb5dfc%s' % arch_ext | |||
r2277 | filename = '%s-%s' % (HG_REPO, short) | |||
r2289 | response = self.app.get(url(controller='files', | |||
r2277 | action='archivefile', | |||
r873 | repo_name=HG_REPO, | |||
fname=fname)) | ||||
r2255 | self.assertEqual(response.status, '200 OK') | |||
r2294 | heads = [ | |||
r2367 | ('Pragma', 'no-cache'), | |||
('Cache-Control', 'no-cache'), | ||||
r2318 | ('Content-Disposition', 'attachment; filename=%s' % filename), | |||
('Content-Type', '%s; charset=utf-8' % info[0]), | ||||
r2294 | ] | |||
self.assertEqual(response.response._headers.items(), heads) | ||||
r873 | ||||
def test_archival_wrong_ext(self): | ||||
self.log_user() | ||||
r3056 | _set_downloads(HG_REPO, set_to=True) | |||
r873 | for arch_ext in ['tar', 'rar', 'x', '..ax', '.zipz']: | |||
fname = '27cd5cce30c96924232dffcd24178a07ffeb5dfc%s' % arch_ext | ||||
r2367 | response = self.app.get(url(controller='files', | |||
r2318 | action='archivefile', | |||
r873 | repo_name=HG_REPO, | |||
fname=fname)) | ||||
r2255 | response.mustcontain('Unknown archive type') | |||
r873 | ||||
def test_archival_wrong_revision(self): | ||||
self.log_user() | ||||
r3056 | _set_downloads(HG_REPO, set_to=True) | |||
r2318 | for rev in ['00x000000', 'tar', 'wrong', '@##$@$42413232', '232dffcd']: | |||
r873 | fname = '%s.zip' % rev | |||
r2318 | response = self.app.get(url(controller='files', | |||
action='archivefile', | ||||
r873 | repo_name=HG_REPO, | |||
fname=fname)) | ||||
r2255 | response.mustcontain('Unknown revision') | |||
r873 | ||||
r1047 | #========================================================================== | |||
# RAW FILE | ||||
#========================================================================== | ||||
def test_raw_file_ok(self): | ||||
self.log_user() | ||||
response = self.app.get(url(controller='files', action='rawfile', | ||||
repo_name=HG_REPO, | ||||
revision='27cd5cce30c96924232dffcd24178a07ffeb5dfc', | ||||
f_path='vcs/nodes.py')) | ||||
r1064 | ||||
r2255 | self.assertEqual(response.content_disposition, "attachment; filename=nodes.py") | |||
self.assertEqual(response.content_type, "text/x-python") | ||||
r1063 | ||||
r1047 | def test_raw_file_wrong_cs(self): | |||
self.log_user() | ||||
r1063 | rev = u'ERRORce30c96924232dffcd24178a07ffeb5dfc' | |||
r1047 | f_path = 'vcs/nodes.py' | |||
response = self.app.get(url(controller='files', action='rawfile', | ||||
repo_name=HG_REPO, | ||||
r1063 | revision=rev, | |||
r3621 | f_path=f_path), status=404) | |||
r1063 | ||||
Bradley M. Kuhn
|
r4116 | msg = """Such revision does not exist for this repository""" | ||
r3621 | response.mustcontain(msg) | |||
r873 | ||||
r1047 | def test_raw_file_wrong_f_path(self): | |||
self.log_user() | ||||
rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' | ||||
f_path = 'vcs/ERRORnodes.py' | ||||
response = self.app.get(url(controller='files', action='rawfile', | ||||
repo_name=HG_REPO, | ||||
revision=rev, | ||||
r3621 | f_path=f_path), status=404) | |||
r1984 | ||||
r3621 | msg = "There is no file nor directory at the given path: '%s' at revision %s" % (f_path, rev[:12]) | |||
response.mustcontain(msg) | ||||
r1047 | ||||
#========================================================================== | ||||
r1064 | # RAW RESPONSE - PLAIN | |||
r1047 | #========================================================================== | |||
def test_raw_ok(self): | ||||
self.log_user() | ||||
response = self.app.get(url(controller='files', action='raw', | ||||
repo_name=HG_REPO, | ||||
revision='27cd5cce30c96924232dffcd24178a07ffeb5dfc', | ||||
f_path='vcs/nodes.py')) | ||||
r1064 | ||||
r2255 | self.assertEqual(response.content_type, "text/plain") | |||
r1063 | ||||
r1047 | def test_raw_wrong_cs(self): | |||
self.log_user() | ||||
r1063 | rev = u'ERRORcce30c96924232dffcd24178a07ffeb5dfc' | |||
r1047 | f_path = 'vcs/nodes.py' | |||
response = self.app.get(url(controller='files', action='raw', | ||||
repo_name=HG_REPO, | ||||
r1063 | revision=rev, | |||
r3621 | f_path=f_path), status=404) | |||
Bradley M. Kuhn
|
r4116 | msg = """Such revision does not exist for this repository""" | ||
r3621 | response.mustcontain(msg) | |||
r1047 | ||||
def test_raw_wrong_f_path(self): | ||||
self.log_user() | ||||
rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' | ||||
f_path = 'vcs/ERRORnodes.py' | ||||
response = self.app.get(url(controller='files', action='raw', | ||||
repo_name=HG_REPO, | ||||
revision=rev, | ||||
r3621 | f_path=f_path), status=404) | |||
msg = "There is no file nor directory at the given path: '%s' at revision %s" % (f_path, rev[:12]) | ||||
response.mustcontain(msg) | ||||
r1749 | ||||
def test_ajaxed_files_list(self): | ||||
self.log_user() | ||||
r1818 | rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' | |||
r1984 | response = self.app.get( | |||
r3621 | url('files_nodelist_home', repo_name=HG_REPO, f_path='/', | |||
revision=rev), | ||||
r1984 | extra_environ={'HTTP_X_PARTIAL_XHR': '1'}, | |||
) | ||||
response.mustcontain("vcs/web/simplevcs/views/repository.py") | ||||
r3621 | ||||
r3839 | #HG - ADD FILE | |||
r3621 | def test_add_file_view_hg(self): | |||
self.log_user() | ||||
response = self.app.get(url('files_add_home', | ||||
repo_name=HG_REPO, | ||||
revision='tip', f_path='/')) | ||||
r3839 | def test_add_file_into_hg_missing_content(self): | |||
self.log_user() | ||||
response = self.app.post(url('files_add_home', | ||||
repo_name=HG_REPO, | ||||
revision='tip', f_path='/'), | ||||
params={ | ||||
r3849 | 'content': '' | |||
r3839 | }, | |||
status=302) | ||||
self.checkSessionFlash(response, 'No content') | ||||
def test_add_file_into_hg_missing_filename(self): | ||||
self.log_user() | ||||
response = self.app.post(url('files_add_home', | ||||
repo_name=HG_REPO, | ||||
revision='tip', f_path='/'), | ||||
params={ | ||||
'content': "foo" | ||||
}, | ||||
status=302) | ||||
self.checkSessionFlash(response, 'No filename') | ||||
@parameterized.expand([ | ||||
('/abs', 'foo'), | ||||
('../rel', 'foo'), | ||||
('file/../foo', 'foo'), | ||||
]) | ||||
def test_add_file_into_hg_bad_filenames(self, location, filename): | ||||
self.log_user() | ||||
response = self.app.post(url('files_add_home', | ||||
repo_name=HG_REPO, | ||||
revision='tip', f_path='/'), | ||||
params={ | ||||
'content': "foo", | ||||
'filename': filename, | ||||
'location': location | ||||
}, | ||||
status=302) | ||||
self.checkSessionFlash(response, 'Location must be relative path and must not contain .. in path') | ||||
@parameterized.expand([ | ||||
(1, '', 'foo.txt'), | ||||
(2, 'dir', 'foo.rst'), | ||||
(3, 'rel/dir', 'foo.bar'), | ||||
]) | ||||
def test_add_file_into_hg(self, cnt, location, filename): | ||||
self.log_user() | ||||
repo = fixture.create_repo('commit-test-%s' % cnt, repo_type='hg') | ||||
response = self.app.post(url('files_add_home', | ||||
repo_name=repo.repo_name, | ||||
revision='tip', f_path='/'), | ||||
params={ | ||||
'content': "foo", | ||||
'filename': filename, | ||||
'location': location | ||||
}, | ||||
status=302) | ||||
try: | ||||
self.checkSessionFlash(response, 'Successfully committed to %s' | ||||
% os.path.join(location, filename)) | ||||
finally: | ||||
fixture.destroy_repo(repo.repo_name) | ||||
##GIT - ADD FILE | ||||
r3621 | def test_add_file_view_git(self): | |||
self.log_user() | ||||
response = self.app.get(url('files_add_home', | ||||
repo_name=GIT_REPO, | ||||
revision='tip', f_path='/')) | ||||
r3839 | def test_add_file_into_git_missing_content(self): | |||
self.log_user() | ||||
response = self.app.post(url('files_add_home', | ||||
repo_name=GIT_REPO, | ||||
revision='tip', f_path='/'), | ||||
params={ | ||||
r3871 | 'content': '' | |||
r3839 | }, | |||
status=302) | ||||
self.checkSessionFlash(response, 'No content') | ||||
def test_add_file_into_git_missing_filename(self): | ||||
self.log_user() | ||||
response = self.app.post(url('files_add_home', | ||||
repo_name=GIT_REPO, | ||||
revision='tip', f_path='/'), | ||||
params={ | ||||
'content': "foo" | ||||
}, | ||||
status=302) | ||||
self.checkSessionFlash(response, 'No filename') | ||||
@parameterized.expand([ | ||||
('/abs', 'foo'), | ||||
('../rel', 'foo'), | ||||
('file/../foo', 'foo'), | ||||
]) | ||||
def test_add_file_into_git_bad_filenames(self, location, filename): | ||||
self.log_user() | ||||
response = self.app.post(url('files_add_home', | ||||
repo_name=GIT_REPO, | ||||
revision='tip', f_path='/'), | ||||
params={ | ||||
'content': "foo", | ||||
'filename': filename, | ||||
'location': location | ||||
}, | ||||
status=302) | ||||
self.checkSessionFlash(response, 'Location must be relative path and must not contain .. in path') | ||||
@parameterized.expand([ | ||||
(1, '', 'foo.txt'), | ||||
(2, 'dir', 'foo.rst'), | ||||
(3, 'rel/dir', 'foo.bar'), | ||||
]) | ||||
def test_add_file_into_git(self, cnt, location, filename): | ||||
self.log_user() | ||||
repo = fixture.create_repo('commit-test-%s' % cnt, repo_type='git') | ||||
response = self.app.post(url('files_add_home', | ||||
repo_name=repo.repo_name, | ||||
revision='tip', f_path='/'), | ||||
params={ | ||||
'content': "foo", | ||||
'filename': filename, | ||||
'location': location | ||||
}, | ||||
status=302) | ||||
try: | ||||
self.checkSessionFlash(response, 'Successfully committed to %s' | ||||
% os.path.join(location, filename)) | ||||
finally: | ||||
fixture.destroy_repo(repo.repo_name) | ||||
#HG - EDIT | ||||
r3621 | def test_edit_file_view_hg(self): | |||
self.log_user() | ||||
response = self.app.get(url('files_edit_home', | ||||
repo_name=HG_REPO, | ||||
revision='tip', f_path='vcs/nodes.py')) | ||||
r3839 | def test_edit_file_view_not_on_branch_hg(self): | |||
self.log_user() | ||||
repo = fixture.create_repo('test-edit-repo', repo_type='hg') | ||||
## add file | ||||
location = 'vcs' | ||||
filename = 'nodes.py' | ||||
response = self.app.post(url('files_add_home', | ||||
repo_name=repo.repo_name, | ||||
revision='tip', f_path='/'), | ||||
params={ | ||||
'content': "def py():\n print 'hello'\n", | ||||
'filename': filename, | ||||
'location': location | ||||
}, | ||||
status=302) | ||||
response.follow() | ||||
try: | ||||
self.checkSessionFlash(response, 'Successfully committed to %s' | ||||
% os.path.join(location, filename)) | ||||
response = self.app.get(url('files_edit_home', | ||||
repo_name=repo.repo_name, | ||||
revision='tip', f_path='vcs/nodes.py'), | ||||
status=302) | ||||
self.checkSessionFlash(response, | ||||
'You can only edit files with revision being a valid branch') | ||||
finally: | ||||
fixture.destroy_repo(repo.repo_name) | ||||
def test_edit_file_view_commit_changes_hg(self): | ||||
self.log_user() | ||||
repo = fixture.create_repo('test-edit-repo', repo_type='hg') | ||||
## add file | ||||
location = 'vcs' | ||||
filename = 'nodes.py' | ||||
response = self.app.post(url('files_add_home', | ||||
repo_name=repo.repo_name, | ||||
revision='tip', | ||||
f_path='/'), | ||||
params={ | ||||
'content': "def py():\n print 'hello'\n", | ||||
'filename': filename, | ||||
'location': location | ||||
}, | ||||
status=302) | ||||
response.follow() | ||||
try: | ||||
self.checkSessionFlash(response, 'Successfully committed to %s' | ||||
% os.path.join(location, filename)) | ||||
response = self.app.post(url('files_edit_home', | ||||
repo_name=repo.repo_name, | ||||
revision=repo.scm_instance.DEFAULT_BRANCH_NAME, | ||||
f_path='vcs/nodes.py'), | ||||
params={ | ||||
'content': "def py():\n print 'hello world'\n", | ||||
'message': 'i commited', | ||||
}, | ||||
status=302) | ||||
self.checkSessionFlash(response, | ||||
'Successfully committed to vcs/nodes.py') | ||||
finally: | ||||
fixture.destroy_repo(repo.repo_name) | ||||
#GIT - EDIT | ||||
r3621 | def test_edit_file_view_git(self): | |||
self.log_user() | ||||
response = self.app.get(url('files_edit_home', | ||||
repo_name=GIT_REPO, | ||||
revision='tip', f_path='vcs/nodes.py')) | ||||
r3839 | ||||
def test_edit_file_view_not_on_branch_git(self): | ||||
self.log_user() | ||||
repo = fixture.create_repo('test-edit-repo', repo_type='git') | ||||
## add file | ||||
location = 'vcs' | ||||
filename = 'nodes.py' | ||||
response = self.app.post(url('files_add_home', | ||||
repo_name=repo.repo_name, | ||||
revision='tip', f_path='/'), | ||||
params={ | ||||
'content': "def py():\n print 'hello'\n", | ||||
'filename': filename, | ||||
'location': location | ||||
}, | ||||
status=302) | ||||
response.follow() | ||||
try: | ||||
self.checkSessionFlash(response, 'Successfully committed to %s' | ||||
% os.path.join(location, filename)) | ||||
response = self.app.get(url('files_edit_home', | ||||
repo_name=repo.repo_name, | ||||
revision='tip', f_path='vcs/nodes.py'), | ||||
status=302) | ||||
self.checkSessionFlash(response, | ||||
'You can only edit files with revision being a valid branch') | ||||
finally: | ||||
fixture.destroy_repo(repo.repo_name) | ||||
def test_edit_file_view_commit_changes_git(self): | ||||
self.log_user() | ||||
repo = fixture.create_repo('test-edit-repo', repo_type='git') | ||||
## add file | ||||
location = 'vcs' | ||||
filename = 'nodes.py' | ||||
response = self.app.post(url('files_add_home', | ||||
repo_name=repo.repo_name, | ||||
revision='tip', | ||||
f_path='/'), | ||||
params={ | ||||
'content': "def py():\n print 'hello'\n", | ||||
'filename': filename, | ||||
'location': location | ||||
}, | ||||
status=302) | ||||
response.follow() | ||||
try: | ||||
self.checkSessionFlash(response, 'Successfully committed to %s' | ||||
% os.path.join(location, filename)) | ||||
response = self.app.post(url('files_edit_home', | ||||
repo_name=repo.repo_name, | ||||
revision=repo.scm_instance.DEFAULT_BRANCH_NAME, | ||||
f_path='vcs/nodes.py'), | ||||
params={ | ||||
'content': "def py():\n print 'hello world'\n", | ||||
'message': 'i commited', | ||||
}, | ||||
status=302) | ||||
self.checkSessionFlash(response, | ||||
'Successfully committed to vcs/nodes.py') | ||||
finally: | ||||
fixture.destroy_repo(repo.repo_name) | ||||
Bradley M. Kuhn
|
r4116 | |||
# HG - delete | ||||
def test_delete_file_view_hg(self): | ||||
self.log_user() | ||||
response = self.app.get(url('files_delete_home', | ||||
repo_name=HG_REPO, | ||||
revision='tip', f_path='vcs/nodes.py')) | ||||
def test_delete_file_view_not_on_branch_hg(self): | ||||
self.log_user() | ||||
repo = fixture.create_repo('test-delete-repo', repo_type='hg') | ||||
## add file | ||||
location = 'vcs' | ||||
filename = 'nodes.py' | ||||
response = self.app.post(url('files_add_home', | ||||
repo_name=repo.repo_name, | ||||
revision='tip', f_path='/'), | ||||
params={ | ||||
'content': "def py():\n print 'hello'\n", | ||||
'filename': filename, | ||||
'location': location | ||||
}, | ||||
status=302) | ||||
response.follow() | ||||
try: | ||||
self.checkSessionFlash(response, 'Successfully committed to %s' | ||||
% os.path.join(location, filename)) | ||||
response = self.app.get(url('files_delete_home', | ||||
repo_name=repo.repo_name, | ||||
revision='tip', f_path='vcs/nodes.py'), | ||||
status=302) | ||||
self.checkSessionFlash(response, | ||||
'You can only delete files with revision being a valid branch') | ||||
finally: | ||||
fixture.destroy_repo(repo.repo_name) | ||||
def test_delete_file_view_commit_changes_hg(self): | ||||
self.log_user() | ||||
repo = fixture.create_repo('test-delete-repo', repo_type='hg') | ||||
## add file | ||||
location = 'vcs' | ||||
filename = 'nodes.py' | ||||
response = self.app.post(url('files_add_home', | ||||
repo_name=repo.repo_name, | ||||
revision='tip', | ||||
f_path='/'), | ||||
params={ | ||||
'content': "def py():\n print 'hello'\n", | ||||
'filename': filename, | ||||
'location': location | ||||
}, | ||||
status=302) | ||||
response.follow() | ||||
try: | ||||
self.checkSessionFlash(response, 'Successfully committed to %s' | ||||
% os.path.join(location, filename)) | ||||
response = self.app.post(url('files_delete_home', | ||||
repo_name=repo.repo_name, | ||||
revision=repo.scm_instance.DEFAULT_BRANCH_NAME, | ||||
f_path='vcs/nodes.py'), | ||||
params={ | ||||
'message': 'i commited', | ||||
}, | ||||
status=302) | ||||
self.checkSessionFlash(response, | ||||
'Successfully deleted file vcs/nodes.py') | ||||
finally: | ||||
fixture.destroy_repo(repo.repo_name) | ||||
# GIT - delete | ||||
def test_delete_file_view_git(self): | ||||
self.log_user() | ||||
response = self.app.get(url('files_delete_home', | ||||
repo_name=HG_REPO, | ||||
revision='tip', f_path='vcs/nodes.py')) | ||||
def test_delete_file_view_not_on_branch_git(self): | ||||
self.log_user() | ||||
repo = fixture.create_repo('test-delete-repo', repo_type='git') | ||||
## add file | ||||
location = 'vcs' | ||||
filename = 'nodes.py' | ||||
response = self.app.post(url('files_add_home', | ||||
repo_name=repo.repo_name, | ||||
revision='tip', f_path='/'), | ||||
params={ | ||||
'content': "def py():\n print 'hello'\n", | ||||
'filename': filename, | ||||
'location': location | ||||
}, | ||||
status=302) | ||||
response.follow() | ||||
try: | ||||
self.checkSessionFlash(response, 'Successfully committed to %s' | ||||
% os.path.join(location, filename)) | ||||
response = self.app.get(url('files_delete_home', | ||||
repo_name=repo.repo_name, | ||||
revision='tip', f_path='vcs/nodes.py'), | ||||
status=302) | ||||
self.checkSessionFlash(response, | ||||
'You can only delete files with revision being a valid branch') | ||||
finally: | ||||
fixture.destroy_repo(repo.repo_name) | ||||
def test_delete_file_view_commit_changes_git(self): | ||||
self.log_user() | ||||
repo = fixture.create_repo('test-delete-repo', repo_type='git') | ||||
## add file | ||||
location = 'vcs' | ||||
filename = 'nodes.py' | ||||
response = self.app.post(url('files_add_home', | ||||
repo_name=repo.repo_name, | ||||
revision='tip', | ||||
f_path='/'), | ||||
params={ | ||||
'content': "def py():\n print 'hello'\n", | ||||
'filename': filename, | ||||
'location': location | ||||
}, | ||||
status=302) | ||||
response.follow() | ||||
try: | ||||
self.checkSessionFlash(response, 'Successfully committed to %s' | ||||
% os.path.join(location, filename)) | ||||
response = self.app.post(url('files_delete_home', | ||||
repo_name=repo.repo_name, | ||||
revision=repo.scm_instance.DEFAULT_BRANCH_NAME, | ||||
f_path='vcs/nodes.py'), | ||||
params={ | ||||
'message': 'i commited', | ||||
}, | ||||
status=302) | ||||
self.checkSessionFlash(response, | ||||
'Successfully deleted file vcs/nodes.py') | ||||
finally: | ||||
fixture.destroy_repo(repo.repo_name) | ||||