Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion Testing recommendations
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
ryan  
View profile  
 More options Apr 9 2008, 7:17 pm
From: ryan <ryanb+appeng...@google.com>
Date: Wed, 9 Apr 2008 16:17:42 -0700 (PDT)
Local: Wed, Apr 9 2008 7:17 pm
Subject: Re: Testing recommendations
Sure! Great question. Here's a snippet that will work with Python's
built-in unittest module. It should be easy to port to other unit test
frameworks. (Note the overlap with the SetupStubs() method in google/
appengine/tools/dev_appserver.py in the SDK.)

from google.appengine.api import apiproxy_stub_map
from google.appengine.api import datastore_file_stub
from google.appengine.api import mail_stub
from google3.apphosting.api import urlfetch_stub
from google3.apphosting.api import user_service_stub

APP_ID = u'test_app'
AUTH_DOMAIN = 'gmail.com'
LOGGED_IN_USER = 't...@example.com'  # set to '' for no logged in user

class MyTest(unittest.TestCase):

 def setUp(self):
   # Ensure we're in UTC.
   os.environ['TZ'] = 'UTC'
   time.tzset()

   # Start with a fresh api proxy.
   apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap()

   # Use a fresh stub datastore.
   stub = datastore_file_stub.DatastoreFileStub(APP_ID, '/dev/null', '/
dev/null')
   apiproxy_stub_map.apiproxy.RegisterStub('datastore_v3', stub)

   # Use a fresh stub UserService.
   apiproxy_stub_map.apiproxy.RegisterStub(
     'user', user_service_stub.UserServiceStub())
   os.environ['AUTH_DOMAIN'] = AUTH_DOMAIN
   os.environ['USER_EMAIL'] = LOGGED_IN_USER

   # Use a fresh urlfetch stub.
   apiproxy_stub_map.apiproxy.RegisterStub(
     'urlfetch', urlfetch_stub.URLFetchServiceStub())

   # Use a fresh mail stub.
   apiproxy_stub_map.apiproxy.RegisterStub(
     'mail', mail_stub.MailServiceStub())


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google