|
| 1 | +#!/usr/bin/env python |
| 2 | +# -*- coding: utf-8 -*- |
| 3 | +# This Source Code Form is subject to the terms of the Mozilla Public |
| 4 | +# License, v. 2.0. If a copy of the MPL was not distributed with this |
| 5 | +# file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 6 | + |
| 7 | +'''Tests for our URI endpoints' rendering.''' |
| 8 | + |
| 9 | +import os.path |
| 10 | +import sys |
| 11 | +import unittest |
| 12 | + |
| 13 | +# Add webcompat module to import path |
| 14 | +sys.path.append(os.path.realpath(os.pardir)) |
| 15 | +import webcompat # nopep8 |
| 16 | + |
| 17 | +# Any request that depends on parsing HTTP Headers (basically anything |
| 18 | +# on the index route, will need to include the following: environ_base=headers |
| 19 | +headers = {'HTTP_USER_AGENT': ('Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; ' |
| 20 | + 'rv:31.0) Gecko/20100101 Firefox/31.0')} |
| 21 | + |
| 22 | + |
| 23 | +class TestURLs(unittest.TestCase): |
| 24 | + def setUp(self): |
| 25 | + webcompat.app.config['TESTING'] = True |
| 26 | + self.app = webcompat.app.test_client() |
| 27 | + |
| 28 | + def tearDown(self): |
| 29 | + pass |
| 30 | + |
| 31 | + def test_titles(self): |
| 32 | + '''Page title format for different URIs.''' |
| 33 | + issueNum = '1000' |
| 34 | + defaultTitle = 'Web Compatibility' |
| 35 | + website_uris = [ |
| 36 | + ('/', defaultTitle), |
| 37 | + ('/about', 'About'), |
| 38 | + ('/contributors', 'Contributors'), |
| 39 | + ('/tools/cssfixme', 'CSS Fix Me'), |
| 40 | + ('/issues/' + issueNum, 'Issue #' + issueNum), |
| 41 | + ('/issues', 'Issues'), |
| 42 | + ('issues/new', 'New Issue'), |
| 43 | + ('/privacy', 'Privacy Policy'), |
| 44 | + ('/404', defaultTitle) |
| 45 | + ] |
| 46 | + for uri, title in website_uris: |
| 47 | + rv = self.app.get(uri, environ_base=headers) |
| 48 | + expected = '<title>{title} | webcompat.com</title>'.format( |
| 49 | + title=title) |
| 50 | + self.assertTrue(expected in rv.data) |
| 51 | + |
| 52 | +if __name__ == '__main__': |
| 53 | + unittest.main() |
0 commit comments