def tearDownModule(): # Let's emit the dev_appserver's logs in case those are helpful. # TODO(csilvers): only emit if there are >0 failures? print print "---------------- START DEV_APPSERVER LOGS ---------------------" print open(handler_test_utils.dev_appserver_logfile_name()).read() print "----------------- END DEV_APPSERVER LOGS ----------------------" oauth_test_client.unstub_for_oauth() oauth_test_client.clear_oauth_tokens_cache() handler_test_utils.stop_dev_appserver()
def tearDownModule(): # Let's emit the dev_appserver's logs in case those are helpful. # TODO(csilvers): only emit if there are >0 failures? print print '---------------- START DEV_APPSERVER LOGS ---------------------' print open(handler_test_utils.dev_appserver_logfile_name()).read() print '----------------- END DEV_APPSERVER LOGS ----------------------' oauth_test_client.unstub_for_oauth() oauth_test_client.clear_oauth_tokens_cache() handler_test_utils.stop_dev_appserver()
def main(db_filename): """Start a dev_appserver, create db entries on it, and exit.""" handler_test_utils.start_dev_appserver() try: stub() print >>sys.stderr, 'Making users' users = Users() print >>sys.stderr, 'Making videos' videos = Videos() print >>sys.stderr, 'Making exercises' exercises = Exercises() print >>sys.stderr, 'Making exercises-and-videos' exercises_and_videos = ExercisesAndVideos(exercises, videos) print >>sys.stderr, 'Watching and doing videos and exercises' users.add_progress(exercises_and_videos) print >>sys.stderr, 'Making topic versions' topic_versions = TopicVersions(users) print >>sys.stderr, 'Making topic trees' unused_topics = Topics(users, topic_versions, exercises, videos) print >>sys.stderr, 'Making map layout' unused_map_layout = MapLayout(topic_versions) print >>sys.stderr, 'Making common core map' unused_common_core_map = CommonCoreMap() # OK, that was enough to create the db. Let's put it in its # official home. print >>sys.stderr, 'Copying out data' shutil.copy(os.path.join(handler_test_utils.tmpdir, 'datastore', 'test.sqlite'), db_filename) print >>sys.stderr, 'Done! Output in %s' % db_filename finally: # We keep around the tmpdir for debugging/etc handler_test_utils.stop_dev_appserver(delete_tmpdir=False)
def main(db_filename): """Start a dev_appserver, create db entries on it, and exit.""" handler_test_utils.start_dev_appserver() try: stub() print >> sys.stderr, 'Making users' users = Users() print >> sys.stderr, 'Making videos' videos = Videos() print >> sys.stderr, 'Making exercises' exercises = Exercises() print >> sys.stderr, 'Making exercises-and-videos' unused_exercises_and_videos = ExercisesAndVideos(exercises, videos) print >> sys.stderr, 'Making topic versions' topic_versions = TopicVersions(users) print >> sys.stderr, 'Making topic trees' unused_topics = Topics(users, topic_versions, exercises, videos) print >> sys.stderr, 'Making map layout' unused_map_layout = MapLayout(topic_versions) print >> sys.stderr, 'Making common core map' unused_common_core_map = CommonCoreMap() # OK, that was enough to create the db. Let's put it in its # official home. print >> sys.stderr, 'Copying out data' shutil.copy( os.path.join(handler_test_utils.tmpdir, 'datastore', 'test.sqlite'), db_filename) print >> sys.stderr, 'Done! Output in %s' % db_filename finally: # We keep around the tmpdir for debugging/etc handler_test_utils.stop_dev_appserver(delete_tmpdir=False)
def main(db_filename): """Start a dev_appserver, create db entries on it, and exit.""" try: with open(db_filename): filename=db_filename except IOError: filename=None handler_test_utils.start_dev_appserver(db=filename) try: stub() from user_models import UserData import csv if filename == None: print >>sys.stderr, 'Making users' Users() print >>sys.stderr, 'Making users:Done' users = UserData.all().fetch(100) with open('users.csv', 'wb') as csvfile: spamwriter = csv.writer(csvfile, delimiter=' ', quotechar='|', quoting=csv.QUOTE_MINIMAL) for u in users: print u.nickname spamwriter.writerow([u.nickname]) print >>sys.stderr, 'Done! Output in %s' % db_filename if filename == None: shutil.copy(os.path.join(handler_test_utils.tmpdir, 'datastore', 'test.sqlite'), db_filename) finally: # We keep around the tmpdir for debugging/etc handler_test_utils.stop_dev_appserver(delete_tmpdir=False)
appengine_tool_setup.fix_sys_path(args.sdk) # These have to be imported after fix_sys_path is called from google.appengine.ext.remote_api import remote_api_stub from testutil import handler_test_utils handler_test_utils.start_dev_appserver( db=args.datastore_path, persist_db_changes=True) remote_api_stub.ConfigureRemoteApi( None, '/_ah/remote_api', auth_func=(lambda: ('test', 'test')), # username/password servername=handler_test_utils.appserver_url[len('http://'):]) try: import IPython IPython.embed() except ImportError: print "=" * 78 print "Looks like you don't have IPython installed." print "If you'd like to use IPython instead of the regular python REPL" print "pip install IPython" print "=" * 78 import code code.interact(local=locals()) finally: handler_test_utils.stop_dev_appserver()