Ejemplo n.º 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()))
Ejemplo n.º 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('')
Ejemplo n.º 3
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()))
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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('')
Ejemplo n.º 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')
Ejemplo n.º 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')