wheezy.routing / demos / hello / test_helloworld.py

""" Unit tests for ``helloworld`` module.
"""

import unittest


class MainTestCase(unittest.TestCase):
    """ Test the ``main`` funcation call.
    """

    def test_hello_match(self):
        """
        """
        from helloworld import main

        def start_response(status, response_headers):
            self.assertEquals('200 OK', status)

        environ = {'PATH_INFO': '/'}
        response = list(map(lambda c: c.decode('utf-8'),
                            main(environ, start_response)))

        self.assertEquals(['Hello World!'], response)

    def test_any_path_match(self):
        """
        """
        from helloworld import main

        def start_response(status, response_headers):
            self.assertEquals('404 Not Found', status)

        for path in ('/a', '/b'):
            environ = {'PATH_INFO': path}
            response = list(map(lambda c: c.decode('utf-8'),
                                main(environ, start_response)))

            self.assertEquals([''], response)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.