Skip to content

Commit

Permalink
Issue webcompat#1858 - Adds tests for routes
Browse files Browse the repository at this point in the history
  • Loading branch information
karlcow committed Nov 7, 2017
1 parent 1626d43 commit 2a7f735
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
12 changes: 7 additions & 5 deletions tests/test_rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ def test_titles(self):
('/issues', 'Issues'),
('issues/new', 'New Issue'),
('/privacy', 'Privacy Policy'),
('/dashboard/triage', 'Triage Dashboard'),
('/404', defaultTitle)
]
for uri, title in website_uris:
rv = self.app.get(uri, environ_base=headers)
expected = '<title>{title} | webcompat.com</title>'.format(
title=title)
self.assertTrue(expected in rv.data)
with webcompat.app.app_context():
for uri, title in website_uris:
rv = self.app.get(uri, environ_base=headers)
expected = '<title>{title} | webcompat.com</title>'.format(
title=title)
self.assertTrue(expected in rv.data)

def test_user_title_pages(self):
"""Testing user activity page title."""
Expand Down
23 changes: 23 additions & 0 deletions tests/test_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,29 @@ def test_new_issue_should_not_crash(self):
rv = self.app.post('/issues/new', data=data)
self.assertEqual(rv.status_code, 400)

def test_dashboard_triage(self):
"""Request to /dashboard/triage should be 200."""
rv = self.app.get('/dashboard/triage')
self.assertEqual(rv.status_code, 200)
self.assertTrue('<h1>Triage Dashboard</h1>' in rv.data)
self.assertTrue('text/html' in rv.content_type)

def test_dashboard_route(self):
"""Request to /dashboard should be 404.
For now, the dashboard route has no purpose.
"""
rv = self.app.get('/dashboard/')
content_test = 'Lost in Punk Cat Space (404)' in rv.data
self.assertEqual(rv.status_code, 404)
self.assertTrue('text/html' in rv.content_type)
self.assertTrue(content_test)
rv = self.app.get('/dashboard')
content_test = 'Lost in Punk Cat Space (404)' in rv.data
self.assertEqual(rv.status_code, 404)
self.assertTrue('text/html' in rv.content_type)
self.assertTrue(content_test)


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

0 comments on commit 2a7f735

Please sign in to comment.