Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Search for the correct file depending on PRETTY_URLS
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Mar 28, 2017
1 parent 24f746b commit 208188d
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions tests/test_integration.py
Expand Up @@ -564,7 +564,8 @@ def fill_site(self):
pages = os.path.join(self.target_dir, "pages")
subdir1 = os.path.join(self.target_dir, "pages", "subdir1")
subdir2 = os.path.join(self.target_dir, "pages", "subdir2")
subdir2 = os.path.join(self.target_dir, "pages", "subdir3")
subdir3 = os.path.join(self.target_dir, "pages", "subdir3")

nikola.utils.makedirs(subdir1)
nikola.utils.makedirs(subdir2)
nikola.utils.makedirs(subdir3)
Expand All @@ -587,6 +588,10 @@ def fill_site(self):
with io.open(os.path.join(subdir3, 'bar.php'), "w+", encoding="utf8") as outf:
outf.write(".. title: Still not the page index\n.. slug: index\n\nThis is not the page index either.\n")

def _make_output_path(self, dir, name):
"""Make a file path to the output."""
return os.path.join(dir, name + '.html')

def test_page_index(self):
"""Test PAGE_INDEX."""
pages = os.path.join(self.target_dir, "output", "pages")
Expand All @@ -595,14 +600,15 @@ def test_page_index(self):
subdir3 = os.path.join(self.target_dir, "output", "pages", "subdir3")

# Do all files exist?
self.assertTrue(os.path.isfile(os.path.join(pages, 'page0.html')))
self.assertTrue(os.path.isfile(self._make_output_path(pages, 'page0')))
self.assertTrue(os.path.isfile(self._make_output_path(subdir1, 'page1')))
self.assertTrue(os.path.isfile(self._make_output_path(subdir1, 'page2')))
self.assertTrue(os.path.isfile(self._make_output_path(subdir2, 'page3')))
self.assertTrue(os.path.isfile(self._make_output_path(subdir3, 'page4')))

self.assertTrue(os.path.isfile(os.path.join(pages, 'index.html')))
self.assertTrue(os.path.isfile(os.path.join(subdir1, 'page1.html')))
self.assertTrue(os.path.isfile(os.path.join(subdir1, 'page2.html')))
self.assertTrue(os.path.isfile(os.path.join(subdir1, 'index.html')))
self.assertTrue(os.path.isfile(os.path.join(subdir2, 'page3.html')))
self.assertTrue(os.path.isfile(os.path.join(subdir2, 'index.html')))
self.assertTrue(os.path.isfile(os.path.join(subdir3, 'page4.html')))
self.assertTrue(os.path.isfile(os.path.join(subdir3, 'index.php')))
self.assertFalse(os.path.isfile(os.path.join(subdir3, 'index.html')))

Expand Down Expand Up @@ -654,5 +660,10 @@ def patch_site(self):
with io.open(conf_path, "a", encoding="utf8") as outf:
outf.write("""\n\nPAGE_INDEX = True\nPRETTY_URLS = True\nPAGES = PAGES + (('pages/*.php', 'pages', 'story.tmpl'),)\n\n""")

def _make_output_path(self, dir, name):
"""Make a file path to the output."""
return os.path.join(dir, name + '/index.html')


if __name__ == "__main__":
unittest.main()

0 comments on commit 208188d

Please sign in to comment.