Mercurial > summit-idp
view tests/test_easy.py @ 67:8be999c3d066
made smoke test more robust
author | Atul Varma <avarma@mozilla.com> |
---|---|
date | Tue, 29 Jun 2010 20:26:18 -0700 |
parents | 50297a64414c |
children |
line wrap: on
line source
import tempfile import shutil import os import json from summitidp.easy import make_wsgi_app from webtest import TestApp def test_ensure_easy_does_not_smoke(): NUM_USERS = 5 users = ['%d@test.com' % i for i in range(NUM_USERS)] tempdir = tempfile.mkdtemp(prefix='smoosh') f = open(os.path.join(tempdir, 'attendees.json'), 'w') f.write(json.dumps(users)) f.close() tokens = [] def send_email(email, token): tokens.append(token) try: wsgiapp = make_wsgi_app(tempdir, send_email) app = TestApp(wsgiapp) def post_json(url, obj, **kwargs): return app.post(url, json.dumps(obj), {'Content-Type': 'application/json'}, **kwargs) for i in range(NUM_USERS): post_json('/challenge/request', {'email': '%d@test.com' % i}) resp = post_json('/challenge/respond', {'token': tokens[-1]}) token = resp.json['token'] post_json('/profile', {'token': token, 'contents': {'stuff': 'o' * 1024}}) for i in range(5): resp = app.get('/profile?token=%s' % token) finally: shutil.rmtree(tempdir)