5 class ValidatingClient(object):
6 def __init__(self, client):
9 def request(self, url, method, exp_status=200, params={}):
10 if not url.startswith('/quotes/'):
11 url = '/quotes/' + url
14 response = self.client.get(url)
15 elif method == 'post':
16 response = self.client.post(url, params)
18 raise RuntimeError('Unknown method %s for %s' % (method, url))
19 assert response.status_code == exp_status
20 if response.status_code != 200:
22 assert response.charset == 'utf-8'
23 document = response.content.decode(response.charset)
24 lxml.etree.fromstring(document)
25 assert '<script>' not in document
28 def getPage(self, url, exp_status=200):
29 return self.request(url, 'get', exp_status=exp_status)
31 def postPage(self, url, params, exp_status=200):
32 return self.request(url, 'post', params=params, exp_status=exp_status)
36 return ValidatingClient(client)
39 def c_adm(admin_client):
40 return ValidatingClient(admin_client)