Test contact page
This commit is contained in:
parent
8078e69430
commit
721074040f
3 changed files with 23 additions and 1 deletions
|
@ -9,7 +9,7 @@ class TestClient:
|
|||
def get(self, path, JS=True):
|
||||
file_path = self.build_path(path)
|
||||
content = "".join(open(file_path).readlines())
|
||||
if path.endswith('html'):
|
||||
if file_path.endswith('html'):
|
||||
content = BeautifulSoup(content, 'html.parser')
|
||||
if JS:
|
||||
for script in content(["noscript"]): # Remove noscript tags
|
||||
|
@ -19,6 +19,8 @@ class TestClient:
|
|||
def build_path(self, path):
|
||||
if path.startswith('/'):
|
||||
path = path[1:]
|
||||
if path.endswith('/'):
|
||||
path += 'index.html'
|
||||
return os.path.join(self.output_path, path)
|
||||
|
||||
def exists(self, path):
|
||||
|
|
|
@ -96,5 +96,11 @@ class TestClientTestCase(TestCase):
|
|||
def test_file_exists(self):
|
||||
self.assertTrue(self.client.exists('index.html'))
|
||||
|
||||
def test_build_path_without_index(self):
|
||||
self.assertEqual(
|
||||
self.client.build_path('foo/'),
|
||||
self.client.build_path('foo/index.html')
|
||||
)
|
||||
|
||||
def test_file_doesnt_exist(self):
|
||||
self.assertFalse(self.client.exists('foo.bar'))
|
||||
|
|
|
@ -70,6 +70,20 @@ class AboutPageTestCase(TestCase):
|
|||
self.assertIn(self.get_children(account.find('h3')), site_names)
|
||||
|
||||
|
||||
class ContactPageTestCase(TestCase):
|
||||
def test_title(self):
|
||||
content = self.client.get('contact/')
|
||||
self.assertHeaderTitle(content, 'Contact Me')
|
||||
self.assertTitle(content, 'Contact Me')
|
||||
|
||||
def test_contact_links(self):
|
||||
content = self.client.get('contact/')
|
||||
links = content.find_all('section')[2].find_all('a')
|
||||
self.assertEqual(links[1].attrs['href'], settings.ACCOUNTS['twitter']['url'])
|
||||
decoded_value = ''.join([chr(int(c)) for c in links[0].attrs['data-value'].split(' ')])
|
||||
self.assertEqual(decoded_value, settings.CONTACT_EMAIL)
|
||||
|
||||
|
||||
class Page404TestCase(TestCase):
|
||||
def test_title(self):
|
||||
content = self.client.get('.404.html')
|
||||
|
|
Reference in a new issue