A setup_fresh_app decorator which should make writing tests a bit easier.
Setting test_register_views() to use it also.
This commit is contained in:
parent
66471f0ee4
commit
3aa4c668b9
@ -19,7 +19,7 @@ import urlparse
|
|||||||
from nose.tools import assert_equal
|
from nose.tools import assert_equal
|
||||||
|
|
||||||
from mediagoblin.auth import lib as auth_lib
|
from mediagoblin.auth import lib as auth_lib
|
||||||
from mediagoblin.tests.tools import get_test_app
|
from mediagoblin.tests.tools import setup_fresh_app
|
||||||
from mediagoblin import globals as mgoblin_globals
|
from mediagoblin import globals as mgoblin_globals
|
||||||
from mediagoblin import util
|
from mediagoblin import util
|
||||||
|
|
||||||
@ -65,13 +65,11 @@ def test_bcrypt_gen_password_hash():
|
|||||||
'notthepassword', hashed_pw, '3><7R45417')
|
'notthepassword', hashed_pw, '3><7R45417')
|
||||||
|
|
||||||
|
|
||||||
def test_register_views():
|
@setup_fresh_app
|
||||||
|
def test_register_views(test_app):
|
||||||
"""
|
"""
|
||||||
Massive test function that all our registration-related views all work.
|
Massive test function that all our registration-related views all work.
|
||||||
"""
|
"""
|
||||||
util.clear_test_template_context()
|
|
||||||
test_app = get_test_app()
|
|
||||||
|
|
||||||
# Test doing a simple GET on the page
|
# Test doing a simple GET on the page
|
||||||
# -----------------------------------
|
# -----------------------------------
|
||||||
|
|
||||||
|
@ -21,6 +21,8 @@ import os, shutil
|
|||||||
from paste.deploy import appconfig, loadapp
|
from paste.deploy import appconfig, loadapp
|
||||||
from webtest import TestApp
|
from webtest import TestApp
|
||||||
|
|
||||||
|
from mediagoblin import util
|
||||||
|
from mediagoblin.decorators import _make_safe
|
||||||
from mediagoblin.db.open import setup_connection_and_db_from_config
|
from mediagoblin.db.open import setup_connection_and_db_from_config
|
||||||
|
|
||||||
|
|
||||||
@ -91,3 +93,17 @@ def get_test_app(dump_old_app=True):
|
|||||||
'config:' + TEST_APP_CONFIG)
|
'config:' + TEST_APP_CONFIG)
|
||||||
|
|
||||||
return TestApp(test_app)
|
return TestApp(test_app)
|
||||||
|
|
||||||
|
|
||||||
|
def setup_fresh_app(func):
|
||||||
|
"""
|
||||||
|
Decorator to setup a fresh test application for this function.
|
||||||
|
|
||||||
|
Cleans out test buckets and passes in a new, fresh test_app.
|
||||||
|
"""
|
||||||
|
def wrapper(*args, **kwargs):
|
||||||
|
test_app = get_test_app()
|
||||||
|
util.clear_test_buckets()
|
||||||
|
return func(test_app, *args, **kwargs)
|
||||||
|
|
||||||
|
return _make_safe(wrapper, func)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user