Skip to content

Commit

Permalink
Added tests for json and fixed missing headers in python3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
defnull committed Aug 11, 2009
1 parent ed1c165 commit 863527a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bottle.py
Expand Up @@ -359,7 +359,7 @@ def wsgiheaders(self):
''' Returns a wsgi conform list of header/value pairs '''
for c in self.COOKIES.itervalues():
self.header.add_header('Set-Cookie', c.OutputString())
return [(h.title(), str(v)) for h, v in self.header_list]
return [(h.title(), str(v)) for h, v in self.header.items()]

@property
def COOKIES(self):
Expand Down
9 changes: 8 additions & 1 deletion test/test_wsgi.py
Expand Up @@ -31,7 +31,7 @@ def simulate(self, url, **kargs):
setup_testing_defaults(environ)
def start_response(status, header):
meta['status'] = int(status.split()[0])
meta['header'] = header
meta['header'] = dict(header)
for part in self.wsgi(environ, start_response):
out += part
return meta['status'], meta['header'], out
Expand All @@ -56,6 +56,13 @@ def test_200(self):
self.assertEqual('test', self.simulate('/page1')[2])
self.assertEqual('test', self.simulate('/page2')[2])

def test_json(self):
""" WSGI: json """
self.wsgi.add_route('/json', lambda: {'a':1})
self.assertEqual(200, self.simulate('/json')[0])
self.assertEqual('application/json', self.simulate('/json')[1].get('Content-Type',''))
self.assertEqual(r'{"a": 1}', self.simulate('/json')[2])


suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestWsgi))
Expand Down

0 comments on commit 863527a

Please sign in to comment.