diff --git a/pelicanconf.py b/pelicanconf.py index 5047cbd..5f37360 100644 --- a/pelicanconf.py +++ b/pelicanconf.py @@ -36,7 +36,7 @@ from plugins import image_resizer META_IMAGES = image_resizer.generate() PIWIK = { 'url': 'piwik.theorangeone.net', - 'site_id': '1' + 'site_id': 1 } # Disable some pages diff --git a/scripts/test b/scripts/test index 94662a3..55d1620 100755 --- a/scripts/test +++ b/scripts/test @@ -7,7 +7,7 @@ FLAKE8_IGNORE=--ignore=E128,E501,E401,E402 set -e -nose2 --verbose +nose2 eslint 'theme/static/src/js/' diff --git a/tests/__init__.py b/tests/__init__.py index 6183f0b..83d67b0 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -29,7 +29,7 @@ class TestCase(unittest.TestCase): client = TestClient() def get_children(self, content): - return str(list(content.children)[0]) + return str(list(content.children)[0]).strip() def assertTitle(self, content, title): self.assertIn(title, content.title.string) @@ -37,3 +37,6 @@ class TestCase(unittest.TestCase): def assertHeaderTitle(self, content, title): header_title = content.find('h1', class_="section-heading") self.assertIn(title, self.get_children(header_title)) + + def assertSamePath(self, p1, p2): + self.assertEqual(self.client.build_path(p1), self.client.build_path(p2)) diff --git a/tests/tests_common.py b/tests/tests_common.py index 7f98edf..bb03aa0 100644 --- a/tests/tests_common.py +++ b/tests/tests_common.py @@ -27,12 +27,13 @@ class CorePagesTestCase(TestCase): content = self.client.get('.404.html') self.assertTitle(content, '404') +class CommonPagesTestCase(TestCase): def test_has_scripts(self): content = self.client.get('index.html') for script in content.find_all('script'): if script.attrs.get('id') == 'piwik': continue - self.client.exists(script.attrs['src']) + self.assertTrue(self.client.exists(script.attrs['src'])) def test_has_stylesheet(self): content = self.client.get('index.html') @@ -53,6 +54,22 @@ class CorePagesTestCase(TestCase): self.assertIn(link.attrs['alt'], social_settings['footer_accounts']) self.assertIn("fa fa-", str(list(link.children)[0])) + def test_navbar_links(self): + content = self.client.get('.404.html') # a page that isnt home + links = content.find('ul', class_='navbar-nav').find_all('a') + self.assertEqual(len(links), 4) + for link in links: + element = self.get_children(link) + self.assertEqual(link.attrs['href'], '/{}/'.format(element.lower())) + self.assertTrue(self.client.exists(link.attrs['href'])) + + def test_navbar_index_link(self): + content = self.client.get('.404.html') # a page that isnt home + link = content.find('a', class_='navbar-brand') + self.assertTrue(self.client.exists(link.attrs['href'])) + self.assertSamePath(link.attrs['href'], '/') + self.assertEqual(self.get_children(link), settings.SITENAME) + @skipIf(not environ.get('BUILD_PRODUCTION', False), 'Not building production') def test_has_analytics(self): content = self.client.get('index.html', False) diff --git a/tests/tests_pages.py b/tests/tests_pages.py index 2e2ffb9..e7ddde2 100644 --- a/tests/tests_pages.py +++ b/tests/tests_pages.py @@ -4,9 +4,21 @@ import os.path class HomepageTestCase(TestCase): + def test_about_section(self): + content = self.client.get('index.html') + about = content.find('section', id='about') + self.assertIsNotNone(about) + about_content = about.find('p') + self.assertNotEqual(self.get_children(about_content), '') + about_link = about.find('a') + self.assertTrue(self.client.exists(about_link.attrs['href'])) + def test_blog_links(self): content = self.client.get('index.html') - blogs = content.find('section', id='blog').find_all('div', class_="col-xs-12") + blog = content.find('section', id='blog') + blog_link = blog.find('a', class_='btn') + self.assertTrue(self.client.exists(blog_link.attrs['href'])) + blogs = blog.find_all('div', class_="col-xs-12") self.assertTrue(len(blogs) <= 4) for post in blogs: url = os.path.join(post.find('a').attrs['href'], 'index.html') @@ -19,6 +31,15 @@ class HomepageTestCase(TestCase): url = os.path.join(project.attrs['href'], 'index.html') self.assertTrue(self.client.exists(url)) + def test_navbar(self): + content = self.client.get('index.html') + links = content.find('ul', class_='navbar-nav').find_all('a') + self.assertEqual(len(links), 5) + for link in links: + self.assertIn('page-scroll', link.attrs['class']) + element = self.get_children(link) + self.assertEqual(link.attrs['href'], '#' + element.lower()) + class AboutPageTestCase(TestCase): def test_title(self):