def test_remaining_url_arg_parser(): with get(webify.wsgify(simplest.app), '/joe?times=10') as r: assert u'200' in r.status assert u'joe' in r.body assert u'Hello, joe!' in r.body assert len(re.findall(u'joe', r.body)) == 10 assert u'Hello, joe!' in r.body
def test_simplest(): with get(webify.wsgify(simplest.app), '/world?times=3') as r: assert u'200' in r.status body = r.body assert u'world' in body assert u'Hello, world!' in body assert len(re.findall('world', body)) == 3
def test_pages(): with get(app, '/list') as r: assert(r.status == '200 OK') body = r.body link = re.findall(r'href="(.*?)"', r.body)[0] assert(link.startswith('/ask_matrix/')) assert(len(link) > 15) with get(app, link) as r: assert(r.status == '200 OK') image_links = re.findall(r'src="(.*?)"', r.body) for link in image_links: assert(link.startswith('/matrix_guess/') or link.startswith('/figure_image/')) assert(len(link) > 15) for link in image_links: with get(app, link) as r: assert(r.status == '200 OK')
def test_simplest_hello(): with get(webify.wsgify(simplest.app), '/') as r: assert u'200' in r.status assert u'world' in r.body assert u'Hello, world!' in r.body assert u'<br />' in r.body assert u'500' not in r.status assert u'Error' not in r.status assert u'Error' not in r.body
def test_generate_random_matrix(): with get(app, '/generate_random_matrix') as r: assert(r.status == '302 Found') #TODO: jperla: check the redirect body = r.body
def test_send_email(): with difference(lambda:len(send_email.mail_server.sent_email)): with get(send_email.wrapped_app, '/static/style.css') as r: assert u'200' in r.status
def test_static_app(): content = u'''div {\n color: blue;\n}\n''' with get(webify.wsgify(standard.app), u'/static/style.css') as r: assert content == r.body
def test_layout(): with get(webify.wsgify(layouts.app), '/hello?name=joe') as r: assert u'200' in r.status assert u'joe' in r.body assert u'Hello, joe!' in r.body assert u'<title>' in r.body
def test_template(): with get(webify.wsgify(first_template.app), '/hello?name=joe') as r: assert u'200' in r.status assert u'joe' in r.body assert u'Hello, joe!' in r.body
def test_redirect(): with get(webify.wsgify(hello.app), '/hello_old/') as r: assert u'302' in r.status assert u'/hello/' in r.body
def test_unicode(): with get(webify.wsgify(simplest.app), '/wểrld?times=3') as r: assert u'200' in r.status assert u'wểrld' in r.body.decode('utf8') assert u'Hello, wểrld!' in r.body.decode('utf8') assert len(re.findall(u'wểrld', r.body.decode('utf8'))) == 3
def test_index(): with get(webify.wsgify(hello.app), '/') as r: assert u'200' in r.status assert u'Hello, world!' in r.body