Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 8f465f7eae
Fetching contributors…

Cannot retrieve contributors at this time

65 lines (48 sloc) 1.958 kB
# Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
import unittest
import cherrypy
import webtest
from google.appengine.ext.testbed import Testbed
from google.appengine.api import users
from handlers.root import Root
class TestCase(unittest.TestCase):
def setUp(self):
self.__users = {}
self.__admins = {}
self.testbed = Testbed()
self.testbed.activate()
self.testbed.init_datastore_v3_stub()
self.testbed.init_user_stub()
self.testapp = webtest.TestApp(cherrypy.Application(Root()))
def tearDown(self):
self.testbed.deactivate()
def normalUser(self, name = None):
if self.__users.has_key(name):
return self.__users[name]
email = 'test-user@example.com'
if name:
email = 'test-user-%s@example.com' % name
self.__users[name] = users.User(email = email)
return self.__users[name]
def adminUser(self, name = None):
if self.__admins.has_key(name):
return self.__admins[name]
email = 'test-admin@example.com'
if name:
email = 'test-admin-%s@example.com' % name
self.__admins[name] = users.User(email = email)
return self.__admins[name]
def beNormalUser(self, name = None):
self.testbed.setup_env(
user_email = self.normalUser(name).email(),
overwrite = True)
def beAdminUser(self, name = None):
self.testbed.setup_env(
user_email = self.adminUser(name).email(),
user_is_admin = '1',
overwrite = True)
def assertErrorPage(self, response):
# TODO(nweiz): Make a better error page that's easier to detect
self.assertTrue(response.html.find('pre', id='traceback') is not None)
Jump to Line
Something went wrong with that request. Please try again.