Example #1
0
 def test_post_submit(self):
     data = {'my_input': 'my_value'}
     encoded_data = to_bytes(urlencode(data))
     response = urlopen(self.base_url + 'submit', encoded_data)
     self.assertEqual(200, response.getcode())
     self.assertEqual(response.headers['Content-type'], 'text/html')
     self.assertIn('Submitted', str(response.read()))
Example #2
0
 def action(environ, start_response):
     response_headers = [
         ('Location', redirect_to),
         ('Content-type', 'text/plain')
     ]
     start_response('302 Found', response_headers)
     return to_bytes('')
 def test_post_submit(self):
     data = {"my_input": "my_value"}
     encoded_data = to_bytes(urlencode(data))
     response = urlopen(self.base_url + "submit", encoded_data)
     self.assertEqual(200, response.getcode())
     self.assertEqual(response.headers["Content-type"], "text/html")
     self.assertIn("Submitted", str(response.read()))
Example #4
0
    def add_html(self, method, path, filename):
        filepath = os.path.join(self.base, filename)
        with open(filepath, 'r') as html_file:
            contents = to_bytes(html_file.read())

        def action(environ, start_response):
            start_response('200 OK', [('Content-Type', 'text/html')])
            return contents

        self.add_route(method, path, action)
Example #5
0
    def add_html(self, method, path, filename):
        filepath = os.path.join(self.base, filename)
        with open(filepath, 'r') as html_file:
            contents = to_bytes(html_file.read())

        def action(environ, start_response):
            start_response(
                '200 OK',
                [('Content-Type', 'text/html')])
            return contents

        self.add_route(method, path, action)
Example #6
0
 def action(environ, start_response):
     response_headers = [('Location', redirect_to),
                         ('Content-type', 'text/plain')]
     start_response('302 Found', response_headers)
     return to_bytes('')
Example #7
0
 def not_found(self):
     """Called if no URL matches."""
     self.start_response('404 NOT FOUND', [('Content-Type', 'text/plain')])
     return to_bytes('Not Found')
Example #8
0
 def not_found(self):
     """Called if no URL matches."""
     self.start_response(
         '404 NOT FOUND',
         [('Content-Type', 'text/plain')])
     return to_bytes('Not Found')