1
Fork 0
This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
theorangeone.net-legacy/tests/tests_pages.py

81 lines
3.1 KiB
Python
Raw Normal View History

2016-09-30 23:13:41 +01:00
from tests import TestCase
2017-01-13 21:41:40 +00:00
from config import social as social_settings
2016-09-11 21:26:30 +01:00
import os.path
class HomepageTestCase(TestCase):
2017-01-14 23:53:18 +00:00
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']))
2016-09-11 21:26:30 +01:00
def test_blog_links(self):
content = self.client.get('index.html')
2017-01-14 23:53:18 +00:00
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")
2016-09-11 21:26:30 +01:00
self.assertTrue(len(blogs) <= 4)
2016-09-30 23:13:41 +01:00
for post in blogs:
2016-09-11 21:26:30 +01:00
url = os.path.join(post.find('a').attrs['href'], 'index.html')
self.assertTrue(self.client.exists(url))
2016-09-30 23:13:41 +01:00
def test_projects(self):
content = self.client.get('index.html')
projects = content.find('section', id='projects').find_all('a', class_='portfolio-box')
for project in projects:
url = os.path.join(project.attrs['href'], 'index.html')
self.assertTrue(self.client.exists(url))
2016-10-02 11:36:21 +01:00
2017-01-14 23:53:18 +00:00
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())
2016-10-02 11:36:21 +01:00
class AboutPageTestCase(TestCase):
def test_title(self):
content = self.client.get('about/index.html')
2017-01-31 21:07:17 +00:00
self.assertHeaderTitle(content, 'About')
2016-10-02 11:36:21 +01:00
self.assertTitle(content, 'About')
def test_website_section(self):
content = self.client.get('about/index.html')
section = content.find('section', id='website')
subtitle = section.find('h2')
2017-01-31 21:07:17 +00:00
self.assertEqual('Website', self.get_children(subtitle))
2016-10-02 11:36:21 +01:00
def test_server_section(self):
content = self.client.get('about/index.html')
section = content.find('section', id='server')
subtitle = section.find('h2')
2017-01-31 21:07:17 +00:00
self.assertEqual('Server', self.get_children(subtitle))
2016-10-02 11:36:21 +01:00
def test_github_card(self):
content = self.client.get('about/index.html')
tags = content.find_all('div', class_='github-card')
self.assertEqual(len(tags), 1)
tag = tags[0]
self.assertEqual('medium', tag.attrs['data-theme'])
2017-01-13 21:41:40 +00:00
self.assertEqual(social_settings['accounts']['github'][1], tag.attrs['data-github'])
2016-10-02 11:36:21 +01:00
class Page404TestCase(TestCase):
def test_title(self):
content = self.client.get('.404.html')
self.assertHeaderTitle(content, 'Uh Oh - There\'s nothing here!')
self.assertTitle(content, '404 - Page not found')
def test_image(self):
content = self.client.get('.404.html')
img = content.find('img')
self.assertEqual('Cat', img.attrs['alt'])