-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest_raequel.py
39 lines (30 loc) · 1.45 KB
/
test_raequel.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# -*- coding: utf-8 -*-
import json
import unittest
import webapp2
import raequel
class TestHandlers(unittest.TestCase):
def test_index(self):
request = webapp2.Request.blank('/')
response = request.get_response(raequel.app)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.headers['Content-Type'], 'text/html; charset=utf-8') # nopep8
def test_json_default_handler(self):
request = webapp2.Request.blank('/json?query=amor')
response = request.get_response(raequel.app)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.headers['Content-Type'], 'application/json')
for lema in json.loads(response.body):
self.assertTrue(isinstance(lema, basestring))
def test_xml_default_handler(self):
request = webapp2.Request.blank('/xml?query=amor')
response = request.get_response(raequel.app)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.headers['Content-Type'], 'application/xml; charset=utf-8') # nopep8
def test_json_v2_handler(self):
request = webapp2.Request.blank('/v2/json?query=amor')
response = request.get_response(raequel.app)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.headers['Content-Type'], 'application/json')
for lema in json.loads(response.body):
self.assertTrue(isinstance(lema, dict))