django context coverage
This commit is contained in:
parent
536eb1f255
commit
f23a51ff6d
2 changed files with 23 additions and 5 deletions
|
@ -17,6 +17,8 @@ class DjangoContext(Vows.Context):
|
|||
|
||||
def __init__(self, parent):
|
||||
super(DjangoContext, self).__init__(parent)
|
||||
if not hasattr(self, '_get_settings'):
|
||||
raise RuntimeError('The context %s needs a _get_settings method that returns the DJANGO_SETTINGS_MODULE environment variable value.' % self.__class__.__name__)
|
||||
os.environ['DJANGO_SETTINGS_MODULE'] = self._get_settings()
|
||||
|
||||
#Gotta set settings environment variable first
|
||||
|
@ -24,10 +26,6 @@ class DjangoContext(Vows.Context):
|
|||
|
||||
setup_test_environment()
|
||||
|
||||
|
||||
def _get_settings(self):
|
||||
return 'settings'
|
||||
|
||||
def _url(self, path):
|
||||
return Url(self, path)
|
||||
|
||||
|
|
|
@ -8,4 +8,24 @@
|
|||
# http://www.opensource.org/licenses/mit-license
|
||||
# Copyright (c) 2011 Rafael Caricio rafael@caricio.com
|
||||
|
||||
from pyvows import Vows
|
||||
from pyvows import Vows, expect
|
||||
|
||||
from django_pyvows.context import DjangoContext
|
||||
|
||||
class DjangoFailedContext(DjangoContext):
|
||||
pass
|
||||
|
||||
@Vows.batch
|
||||
class ContextTest(Vows.Context):
|
||||
|
||||
def topic(self):
|
||||
return DjangoFailedContext(self)
|
||||
|
||||
def should_be_an_error(self, topic):
|
||||
expect(topic).to_be_an_error()
|
||||
|
||||
def should_be_runtime_error(self, topic):
|
||||
expect(topic).to_be_an_error_like(RuntimeError)
|
||||
|
||||
def should_have_nice_error_message(self, topic):
|
||||
expect(topic).to_have_an_error_message_of('The context DjangoFailedContext needs a _get_settings method that returns the DJANGO_SETTINGS_MODULE environment variable value.')
|
||||
|
|
Reference in a new issue