def setUpModule():
    handler_test_utils.start_dev_appserver(db='testutil/test_db.sqlite')
    remote_api_stub.ConfigureRemoteApi(
        None,
        '/_ah/remote_api',
        auth_func=(lambda: ('test', 'test')),  # username/password
        servername=handler_test_utils.appserver_url[len('http://'):])
    oauth_test_client.stub_for_oauth()
Beispiel #2
0
def setUpModule():
    handler_test_utils.start_dev_appserver(db="testutil/test_db.sqlite")
    remote_api_stub.ConfigureRemoteApi(
        None,
        "/_ah/remote_api",
        auth_func=(lambda: ("test", "test")),  # username/password
        servername=handler_test_utils.appserver_url[len("http://") :],
    )
    oauth_test_client.stub_for_oauth()
Beispiel #3
0
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)
Beispiel #5
0
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)
Beispiel #6
0
    # whether we're interfacing with the remote API.
    #
    # Without this, anything using ensure_in_transaction won't work properly
    #
    # This has to be done before fix_sys_path, because fix_sys_path sets its
    # own SERVER_SOFTWARE if one isn't already defined.
    os.environ['SERVER_SOFTWARE'] = 'Development (devshell remote-api)/1.0'

    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"