You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2012/09/19 20:43:27 UTC

[44/50] git commit: [#4334] ticket:158 Add test for `index.*` files in code browser

[#4334] ticket:158 Add test for `index.*` files in code browser


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/6a83d74d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/6a83d74d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/6a83d74d

Branch: refs/heads/master
Commit: 6a83d74d38c5d93646b8c06e79aaa2008fc74fdc
Parents: cbff0bd
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Aug 31 14:31:42 2012 +0300
Committer: Dave Brondsema <db...@geek.net>
Committed: Thu Sep 6 19:36:55 2012 +0000

----------------------------------------------------------------------
 .../forgegit/tests/functional/test_controllers.py  |   42 +++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6a83d74d/ForgeGit/forgegit/tests/functional/test_controllers.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/functional/test_controllers.py b/ForgeGit/forgegit/tests/functional/test_controllers.py
index af25826..6c136b5 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -36,6 +36,20 @@ class _TestCase(TestController):
         ThreadLocalORMSession.flush_all()
         # ThreadLocalORMSession.close_all()
 
+    @td.with_tool('test', 'Git', 'testgit-index', 'Git', type='git')
+    def setup_testgit_index_repo(self):
+        h.set_context('test', 'testgit-index', neighborhood='Projects')
+        repo_dir = pkg_resources.resource_filename(
+            'forgegit', 'tests/data')
+        c.app.repo.fs_path = repo_dir
+        c.app.repo.status = 'ready'
+        c.app.repo.name = 'testgit_index.git'
+        ThreadLocalORMSession.flush_all()
+        h.set_context('test', 'testgit-index', neighborhood='Projects')
+        c.app.repo.refresh()
+        ThreadLocalORMSession.flush_all()
+
+
 class TestRootController(_TestCase):
 
     def test_status(self):
@@ -149,6 +163,34 @@ class TestRootController(_TestCase):
         assert re.search(r'<pre>.*This is readme', content), content
         assert '</pre>' in content, content
 
+    def test_index_files(self):
+        """Test that `index.*` files are viewable in code browser"""
+        self.setup_testgit_index_repo()
+        ci = '/p/test/testgit-index/ci/eaec8e7fc91f18d6bf294379d16146ef9226a1ab/'
+
+        # `index.html` in repo root
+        r = self.app.get(ci + 'tree/index.html')
+        header = r.html.find('h2', {'class': 'dark title'}).contents[2]
+        assert 'index.html' in header, header
+        content = str(r.html.find('div', {'class': 'clip grid-19'}))
+        assert ('<span class="nt">&lt;h1&gt;</span>'
+                'index.html'
+                '<span class="nt">&lt;/h1&gt;</span>') in content, content
+
+        # `index` dir in repo root
+        r = self.app.get(ci + 'tree/index/')
+        assert 'inside_index_dir.txt' in r
+
+        # `index.htm` in `index` dir
+        r = self.app.get(ci + 'tree/index/index.htm')
+        header = r.html.find('h2', {'class': 'dark title'})
+        assert 'index' in header.contents[3], header.contents[3]
+        assert 'index.htm' in header.contents[4], header.contents[4]
+        content = str(r.html.find('div', {'class': 'clip grid-19'}))
+        assert ('<span class="nt">&lt;h1&gt;</span>'
+                'index/index.htm'
+                '<span class="nt">&lt;/h1&gt;</span>') in content, content
+
 
 class TestRestController(_TestCase):