1
Fork 0

Test index sections

This commit is contained in:
Jake Howard 2017-05-22 21:19:45 +01:00
parent 950df28f82
commit aee9996704
2 changed files with 20 additions and 3 deletions

View file

@ -46,7 +46,7 @@
<h3>Setup</h3> <h3>Setup</h3>
</a> </a>
<p> <p>
{{ .Params.summary | default .Summary | truncate .Site.Params.summary_length_long "..." }} {{ .Params.summary | default .Summary | truncate .Site.Params.summary_length_long "..." }}
</p> </p>
{{ end }} {{ end }}
</section> </section>
@ -58,7 +58,7 @@
</div> </div>
</section> </section>
<div class="box special"> <div class="box special" id="projects">
<h2>Projects</h2> <h2>Projects</h2>
<div class="row"> <div class="row">
{{ range first .Site.Params.index_items (where .Data.Pages.ByDate "Section" "projects") }} {{ range first .Site.Params.index_items (where .Data.Pages.ByDate "Section" "projects") }}
@ -68,7 +68,7 @@
<h4><a href="/projects/">All Projects</a></h4> <h4><a href="/projects/">All Projects</a></h4>
</div> </div>
<div class="box special"> <div class="box special" id="recent-posts">
<h2>Recent Posts</h2> <h2>Recent Posts</h2>
<div class="row"> <div class="row">
{{ range first .Site.Params.index_items (where .Data.Pages.ByDate "Section" "!=" "") }} {{ range first .Site.Params.index_items (where .Data.Pages.ByDate "Section" "!=" "") }}

17
tests/tests_pages.py Normal file
View file

@ -0,0 +1,17 @@
from tests import TestCase
class IndexPageTestCase(TestCase):
def test_index_sections(self):
for section in ['projects', 'recent-posts']:
content = self.client.get('index.html')
rows = content.find('div', id=section).find_all('div', class_='row')
self.assertLessEqual(len(rows), self.settings['params']['index_items'])
self.assertGreater(self.settings['params']['index_items'], 0)
for row in rows:
self.assertIsNotNone(row.find('section', class_='box'))
self.assertTrue(self.client.exists(row.find('a').attrs['href']))
self.assertNotEqual(self.get_children(row.find('p')), '')
self.assertLessEqual(len(self.get_children(row.find('p'))), self.settings['params']['summary_length'])
self.assertNotEqual(self.get_children(row.find('h3')), '')