diff --git a/rhodecode/tests/functional/test_files.py b/rhodecode/tests/functional/test_files.py --- a/rhodecode/tests/functional/test_files.py +++ b/rhodecode/tests/functional/test_files.py @@ -6,6 +6,7 @@ ARCHIVE_SPECS = { '.zip': ('application/zip', 'zip', ''), } + class TestFilesController(TestController): def test_index(self): @@ -15,32 +16,29 @@ class TestFilesController(TestController revision='tip', f_path='/')) # Test response... - assert 'docs' in response.body, 'missing dir' - assert 'tests' in response.body, 'missing dir' - assert 'vcs' in response.body, 'missing dir' - assert '.hgignore' in response.body, 'missing file' - assert 'MANIFEST.in' in response.body, 'missing file' - + response.mustcontain('docs') + response.mustcontain('tests') + response.mustcontain('vcs') + response.mustcontain('.hgignore') + response.mustcontain('MANIFEST.in') def test_index_revision(self): self.log_user() - response = self.app.get(url(controller='files', action='index', - repo_name=HG_REPO, - revision='7ba66bec8d6dbba14a2155be32408c435c5f4492', - f_path='/')) - - + response = self.app.get( + url(controller='files', action='index', + repo_name=HG_REPO, + revision='7ba66bec8d6dbba14a2155be32408c435c5f4492', + f_path='/') + ) #Test response... - assert 'docs' in response.body, 'missing dir' - assert 'tests' in response.body, 'missing dir' - assert 'README.rst' in response.body, 'missing file' - assert '1.1 KiB' in response.body, 'missing size of setup.py' - assert 'text/x-python' in response.body, 'missing mimetype of setup.py' - - + response.mustcontain('docs') + response.mustcontain('tests') + response.mustcontain('README.rst') + response.mustcontain('1.1 KiB') + response.mustcontain('text/x-python') def test_index_different_branch(self): self.log_user() @@ -50,11 +48,7 @@ class TestFilesController(TestController revision='97e8b885c04894463c51898e14387d80c30ed1ee', f_path='/')) - - - assert """branch: git""" in response.body, 'missing or wrong branch info' - - + response.mustcontain("""branch: git""") def test_index_paging(self): self.log_user() @@ -70,7 +64,7 @@ class TestFilesController(TestController revision=r[1], f_path='/')) - assert """@ r%s:%s""" % (r[0], r[1][:12]) in response.body, 'missing info about current revision' + response.mustcontain("""@ r%s:%s""" % (r[0], r[1][:12])) def test_file_source(self): self.log_user() @@ -80,40 +74,40 @@ class TestFilesController(TestController f_path='vcs/nodes.py')) #test or history - assert """ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + response.mustcontain(""" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -126,16 +120,15 @@ class TestFilesController(TestController -""" in response.body +""") - - assert """
Partially implemented #16. filecontent/commit message/author/node name are safe_unicode now. + response.mustcontain("""
Partially implemented #16. 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.
""" in response.body +removed extra unicode conversion in diff.
""") - assert """branch: default""" in response.body, 'missing or wrong branch info' + response.mustcontain("""branch: default""") def test_file_annotation(self): self.log_user() @@ -144,41 +137,41 @@ removed extra unicode conversion in diff revision='27cd5cce30c96924232dffcd24178a07ffeb5dfc', f_path='vcs/nodes.py')) - print response.body - assert """ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + response.mustcontain(""" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -191,11 +184,10 @@ removed extra unicode conversion in diff -""" in response.body, 'missing or wrong history in annotation' + +""") - assert """branch: default""" in response.body, 'missing or wrong branch info' - - + response.mustcontain("""branch: default""") def test_archival(self): self.log_user() @@ -260,10 +252,11 @@ removed extra unicode conversion in diff revision=rev, f_path=f_path)) - assert """Revision %r does not exist for this repository""" % (rev) in response.session['flash'][0][1], 'No flash message' - assert """%s""" % (HG_REPO) in response.session['flash'][0][1], 'No flash message' + msg = """Revision %r does not exist for this repository""" % (rev) + self.checkSessionFlash(response, msg) - + msg = """%s""" % (HG_REPO) + self.checkSessionFlash(response, msg) def test_raw_file_wrong_f_path(self): self.log_user() @@ -273,7 +266,9 @@ removed extra unicode conversion in diff repo_name=HG_REPO, revision=rev, f_path=f_path)) - assert "There is no file nor directory at the given path: %r at revision %r" % (f_path, rev[:12]) in response.session['flash'][0][1], 'No flash message' + + msg = "There is no file nor directory at the given path: %r at revision %r" % (f_path, rev[:12]) + self.checkSessionFlash(response, msg) #========================================================================== # RAW RESPONSE - PLAIN @@ -296,10 +291,11 @@ removed extra unicode conversion in diff repo_name=HG_REPO, revision=rev, f_path=f_path)) + msg = """Revision %r does not exist for this repository""" % (rev) + self.checkSessionFlash(response, msg) - assert """Revision %r does not exist for this repository""" % (rev) in response.session['flash'][0][1], 'No flash message' - assert """%s""" % (HG_REPO) in response.session['flash'][0][1], 'No flash message' - + msg = """%s""" % (HG_REPO) + self.checkSessionFlash(response, msg) def test_raw_wrong_f_path(self): self.log_user() @@ -309,15 +305,14 @@ removed extra unicode conversion in diff repo_name=HG_REPO, revision=rev, f_path=f_path)) - - assert "There is no file nor directory at the given path: %r at revision %r" % (f_path, rev[:12]) in response.session['flash'][0][1], 'No flash message' + msg = "There is no file nor directory at the given path: %r at revision %r" % (f_path, rev[:12]) + self.checkSessionFlash(response, msg) def test_ajaxed_files_list(self): self.log_user() rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' - response = self.app.get(url('files_nodelist_home',repo_name=HG_REPO, - f_path='/', - revision=rev), - extra_environ={'HTTP_X_PARTIAL_XHR':'1'}, - ) - self.assertTrue("vcs/web/simplevcs/views/repository.py" in response.body) + response = self.app.get( + url('files_nodelist_home', repo_name=HG_REPO,f_path='/',revision=rev), + extra_environ={'HTTP_X_PARTIAL_XHR': '1'}, + ) + response.mustcontain("vcs/web/simplevcs/views/repository.py")