﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	resolution	keywords	cc	parents
23	Structure for testing views via webtest	Christopher Allan Webber	Christopher Allan Webber	"{{{
#!rst
We need to start testing views to make sure they work right. Right
now we should create a ""test app"" to start testing things in.

Use webtest:
`http://pythonpaste.org/webtest/ <http://pythonpaste.org/webtest/>`_

The testing app should be importable from something like:

            from mediagoblin.tests.tools import get\_test\_app
            test\_app, webtest\_app = get\_test\_app()




where the test\_app is the MediaGoblinApp instance and webtest\_app
is a wrapped instance in webtest.

The testapp should do the following things:


-  create a new database with the database name
   '**mediagoblinunittests**' or something with the default connection
   settings, dumping an old database if it exists
-  Attach a mediagoblin.app.MediaGoblinApp instance to webtest with
   that database... see the structure of paste\_app\_factory to see
   how to do this
-  create a public\_store and a queue\_store that write to
   temporary directories. Use tempfile.mkdtemp() to create these
   directories
-  when calling setup\_celery\_from\_config it should make sure the
   mongodb database that it calls is the *mediagoblinunittests*
   database we created.

One note: cache the database connection in a global variable like
mediagoblin.tests.tools.DATABASE\_CONNECTION and also note whether
celery is set up in mediagoblin.tests.tools.CELERY\_IS\_SET\_UP...
we should only set up celery once :)



}}}"	defect	closed	major	0.0.3	programming	FIXED			
