Browse files

added test documentation in readme and in, edited init so …

…that gae mini profiler is loaded inly in development and not in testing, added unittest2 to dependencies
  • Loading branch information...
1 parent c5b53f2 commit 3a47457417580875335f161337f769c362cf30b0 @pawelmhm pawelmhm committed Oct 15, 2013
Showing with 60 additions and 31 deletions.
  1. +30 −0
  2. +1 −1 requirements_dev.txt
  3. +11 −15 src/application/
  4. +18 −15 src/
@@ -88,6 +88,36 @@ The handy Flask-Cache extension is included, pre-configured for App Engine's Mem
Use the "Flush Cache" button at http://localhost:8000/memcache to clear the cache.
+Place all your tests in src/tests directory. Test runner is placed in src directory. To run your tests simply go to src directory and do:
+<pre class="console">
+ python path/to/your/googleappengine/installation
+Path to your local google app engine installation must be provided as first argument to the script. If the path is long and you don't like to type it each time you run the tests you can also hardcode it in, just edit the variable SDK_PATH and set it to your google app engine folder.
+Before running tests set evironment variable FLASK_CONF to the value TEST.
+In Linux this is done by:
+<pre class="console">
+In Powershell:
+<pre class="console">
+ [Environment]::SetEnvironmentVariable("FLASK_CONF", "TEST", "User");
+Remember to restart Powershell. Change of environment variable will take place after restarting Powershell.
+You can specify your testing configuration (e.g. separate database for tests results) in src/application/
+To switch back to development configuration just set FLASK_CONF to DEV.
Deploying the Application
To deploy the application to App Engine, use [ update][appcfg]
@@ -4,4 +4,4 @@
@@ -4,37 +4,33 @@
from flask import Flask
import os
from flask_debugtoolbar import DebugToolbarExtension
from werkzeug.debug import DebuggedApplication
app = Flask('application')
if os.getenv('FLASK_CONF') == 'DEV':
- #development settings not to be used in production
+ #development settings n
# Flask-DebugToolbar (only enabled when DEBUG=True)
toolbar = DebugToolbarExtension(app)
- # Werkzeug Debugger - enabled by default in new versions of Flask
- #if you set debug to true, right?
- # app.wsgi_app = DebuggedApplication(app.wsgi_app, evalex=True)
+ # Google app engine mini profiler
+ #
+ app.wsgi_app = DebuggedApplication(app.wsgi_app, evalex=True)
+ from gae_mini_profiler import profiler, templatetags
+ @app.context_processor
+ def inject_profiler():
+ return dict(profiler_includes=templatetags.profiler_includes())
+ app.wsgi_app = profiler.ProfilerWSGIMiddleware(app.wsgi_app)
elif os.getenv('FLASK_CONF') == 'TEST':
-# Remember to set SERVER_SOFTWARE environment variable
-# to value "Devel" to use this
-from gae_mini_profiler import profiler, templatetags
-def inject_profiler():
- return dict(profiler_includes=templatetags.profiler_includes())
-app.wsgi_app = profiler.ProfilerWSGIMiddleware(app.wsgi_app)
# Enable jinja2 loop controls extension
@@ -1,22 +1,20 @@
import sys, os
-# Install the Python unittest2 package before you run this script.
import unittest2
-# I kept getting waranings complaining that all modules
-# imported by code in application folder are already in the path
-# I'm not sure how to fix this, and this type of warning
-# is not an error, so I just ignore them
import warnings
+# silences Python's complaints about imports
USAGE = """
+Path to your sdk must be the first argument. To run type:
$ path/to/your/appengine/installation
-Path to your sdk must be the first argument
+Remember to set environment variable FLASK_CONF to TEST.
+Loading configuration depending on the value of
+environment variable allows you to add your own
+testing configuration in src/application/
def main(sdk_path, test_path):
@@ -27,10 +25,15 @@ def main(sdk_path, test_path):
suite = unittest2.loader.TestLoader().discover(test_path)
if __name__ == '__main__':
- #See:
- #Path to the SDK installation
- SDK_PATH = sys.argv[1]#u"/home/pawel/py/plays/appengine/google_appengine/"
- #Path to tests folder
- TEST_PATH = os.path.join(os.path.dirname(os.path.abspath(__name__)),'tests')
+ #See:
+ try:
+ #Path to the SDK installation
+ SDK_PATH = sys.argv[1] # ...or hardcoded path
+ #Path to tests folder
+ TEST_PATH = os.path.join(os.path.dirname(os.path.abspath(__name__)),'tests')
+ except IndexError:
+ # you probably forgot about path as first argument
+ print USAGE

0 comments on commit 3a47457

Please sign in to comment.