Support to unique test configuration
This commit is contained in:
parent
c86a0917cb
commit
9601828618
11 changed files with 47 additions and 24 deletions
|
@ -1,4 +1,3 @@
|
||||||
#!/usr/bin/python
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# django-pyvows extensions
|
# django-pyvows extensions
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#!/usr/bin/python
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# django-pyvows extensions
|
# django-pyvows extensions
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#!/usr/bin/python
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# django-pyvows extensions
|
# django-pyvows extensions
|
||||||
|
@ -20,15 +19,19 @@ from django_pyvows.settings_helpers import SettingsOverrideSupport
|
||||||
class DjangoContext(Vows.Context, HttpClientSupport, SettingsOverrideSupport):
|
class DjangoContext(Vows.Context, HttpClientSupport, SettingsOverrideSupport):
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
super(DjangoContext, self).__init__(parent)
|
super(DjangoContext, self).__init__(parent)
|
||||||
|
|
||||||
HttpClientSupport.__init__(self)
|
HttpClientSupport.__init__(self)
|
||||||
SettingsOverrideSupport.__init__(self)
|
SettingsOverrideSupport.__init__(self)
|
||||||
self.ignore('start_environment', 'settings_module')
|
|
||||||
|
self.ignore('setup_environment', 'settings_module')
|
||||||
|
|
||||||
|
DjangoContext.setup_environment(self.settings_module())
|
||||||
|
|
||||||
def settings_module(self):
|
def settings_module(self):
|
||||||
return 'settings'
|
return 'settings'
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def start_environment(cls, settings_module):
|
def setup_environment(cls, settings_module):
|
||||||
if not settings_module:
|
if not settings_module:
|
||||||
raise ValueError('The settings_path argument is required.')
|
raise ValueError('The settings_path argument is required.')
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
#!/usr/bin/python
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# django-pyvows extensions
|
||||||
|
# https://github.com/rafaelcaricio/django-pyvows
|
||||||
|
|
||||||
|
# Licensed under the MIT license:
|
||||||
|
# http://www.opensource.org/licenses/mit-license
|
||||||
|
# Copyright (c) 2011 Rafael Caricio rafael@caricio.com
|
||||||
|
|
||||||
|
|
||||||
class HttpClientSupport(object):
|
class HttpClientSupport(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# django-pyvows extensions
|
||||||
|
# https://github.com/rafaelcaricio/django-pyvows
|
||||||
|
|
||||||
|
# Licensed under the MIT license:
|
||||||
|
# http://www.opensource.org/licenses/mit-license
|
||||||
|
# Copyright (c) 2011 Rafael Caricio rafael@caricio.com
|
||||||
|
|
||||||
|
|
||||||
class SettingsOverrideSupport(object):
|
class SettingsOverrideSupport(object):
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#!/usr/bin/python
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# django-pyvows extensions
|
# django-pyvows extensions
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#!/usr/bin/python
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# django-pyvows extensions
|
# django-pyvows extensions
|
||||||
|
@ -10,9 +9,7 @@
|
||||||
|
|
||||||
from pyvows import Vows, expect
|
from pyvows import Vows, expect
|
||||||
|
|
||||||
from django_pyvows.context import DjangoContext
|
from test_config import ConfiguredVowsContext as DjangoContext
|
||||||
|
|
||||||
DjangoContext.start_environment("sandbox.sandbox.settings")
|
|
||||||
|
|
||||||
|
|
||||||
@Vows.batch
|
@Vows.batch
|
||||||
|
|
|
@ -7,16 +7,10 @@
|
||||||
# Licensed under the MIT license:
|
# Licensed under the MIT license:
|
||||||
# http://www.opensource.org/licenses/mit-license
|
# http://www.opensource.org/licenses/mit-license
|
||||||
# Copyright (c) 2011 Rafael Caricio rafael@caricio.com
|
# Copyright (c) 2011 Rafael Caricio rafael@caricio.com
|
||||||
from os.path import abspath, join, dirname
|
|
||||||
|
|
||||||
from pyvows import Vows, expect
|
from pyvows import Vows, expect
|
||||||
|
|
||||||
from django_pyvows.context import DjangoContext
|
from test_config import ConfiguredVowsContext as DjangoContext
|
||||||
|
|
||||||
|
|
||||||
TEST_FILE_PATH = abspath(join(dirname(__file__), 'fixtures/the_file.txt'))
|
|
||||||
|
|
||||||
DjangoContext.start_environment("sandbox.sandbox.settings")
|
|
||||||
|
|
||||||
|
|
||||||
@Vows.batch
|
@Vows.batch
|
||||||
|
@ -48,14 +42,14 @@ class DjangoHTTPTestClientCompatibilityVows(DjangoContext):
|
||||||
|
|
||||||
class PostFile(DjangoContext):
|
class PostFile(DjangoContext):
|
||||||
def topic(self):
|
def topic(self):
|
||||||
return self.post('/post_file/', {'the_file': open(TEST_FILE_PATH)})
|
return self.post('/post_file/', {'the_file': open(self.TEST_FILE_PATH)})
|
||||||
|
|
||||||
def should_be_posted_to_the_server(self, topic):
|
def should_be_posted_to_the_server(self, topic):
|
||||||
expect(topic.content).to_equal("the contents")
|
expect(topic.content).to_equal("the contents")
|
||||||
|
|
||||||
class WhenNotFound(DjangoContext):
|
class WhenNotFound(DjangoContext):
|
||||||
def topic(self):
|
def topic(self):
|
||||||
return self.post('/post_/', {'the_file': open(TEST_FILE_PATH)})
|
return self.post('/post_/', {'the_file': open(self.TEST_FILE_PATH)})
|
||||||
|
|
||||||
def should_be_404(self, topic):
|
def should_be_404(self, topic):
|
||||||
expect(topic.status_code).to_equal(404)
|
expect(topic.status_code).to_equal(404)
|
||||||
|
|
|
@ -19,7 +19,7 @@ class ContextTest(Vows.Context):
|
||||||
|
|
||||||
@capture_error
|
@capture_error
|
||||||
def topic(self):
|
def topic(self):
|
||||||
return DjangoContext.start_environment(None)
|
return DjangoContext.setup_environment(None)
|
||||||
|
|
||||||
def should_be_an_error(self, topic):
|
def should_be_an_error(self, topic):
|
||||||
expect(topic).to_be_an_error()
|
expect(topic).to_be_an_error()
|
||||||
|
|
|
@ -11,9 +11,7 @@
|
||||||
from pyvows import Vows, expect
|
from pyvows import Vows, expect
|
||||||
from django.test.utils import override_settings
|
from django.test.utils import override_settings
|
||||||
|
|
||||||
from django_pyvows.context import DjangoContext
|
from test_config import ConfiguredVowsContext as DjangoContext
|
||||||
|
|
||||||
DjangoContext.start_environment("sandbox.sandbox.settings")
|
|
||||||
|
|
||||||
|
|
||||||
@Vows.batch
|
@Vows.batch
|
||||||
|
|
20
vows/test_config.py
Normal file
20
vows/test_config.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# django-pyvows extensions
|
||||||
|
# https://github.com/rafaelcaricio/django-pyvows
|
||||||
|
|
||||||
|
# Licensed under the MIT license:
|
||||||
|
# http://www.opensource.org/licenses/mit-license
|
||||||
|
# Copyright (c) 2011 Rafael Caricio rafael@caricio.com
|
||||||
|
|
||||||
|
from os.path import abspath, join, dirname
|
||||||
|
|
||||||
|
from django_pyvows.context import DjangoContext
|
||||||
|
|
||||||
|
|
||||||
|
class ConfiguredVowsContext(DjangoContext):
|
||||||
|
def settings_module(self):
|
||||||
|
return 'sandbox.sandbox.settings'
|
||||||
|
|
||||||
|
def setup(self):
|
||||||
|
self.TEST_FILE_PATH = abspath(join(dirname(__file__), 'fixtures/the_file.txt'))
|
Reference in a new issue