Does not need to be compatible

This commit is contained in:
Rafael Caricio 2015-07-18 23:03:45 +02:00
parent c3d05f9714
commit 242bb9df19
3 changed files with 18 additions and 33 deletions

View file

@ -31,8 +31,7 @@ class DjangoContext(Vows.Context):
def __init__(self, parent):
super(DjangoContext, self).__init__(parent)
self.ignore('template', 'request', 'model', 'url', 'find_in_parent',
'start_environment', 'settings', 'modify_settings', 'get', 'post')
self.ignore('start_environment', 'settings', 'modify_settings', 'get', 'post')
def settings(self, **kwargs):
from django.test.utils import override_settings
@ -42,8 +41,8 @@ class DjangoContext(Vows.Context):
from django.test.utils import modify_settings
return modify_settings(**kwargs)
def get(self, path):
return http_helpers.get(path)
def get(self, *args, **kwargs):
return http_helpers.get(*args, **kwargs)
def post(self, path, params):
return http_helpers.post(path, params)
def post(self, *args, **kwargs):
return http_helpers.post(*args, **kwargs)

View file

@ -2,27 +2,13 @@
# -*- coding: utf-8 -*-
class RetrocompatibleResponse(object):
def __init__(self, response):
self.response = response
@property
def status(self):
return self.response.status_code
def __iter__(self):
yield self
yield self.response.content
def get(url):
def get(*args, **kwargs):
from django.test.client import Client
client = Client()
resp = client.get(url)
return RetrocompatibleResponse(resp), resp.content
return client.get(*args, **kwargs)
def post(url, data):
def post(*args, **kwargs):
from django.test.client import Client
client = Client()
return RetrocompatibleResponse(client.post(url, data))
return client.post(*args, **kwargs)

View file

@ -16,7 +16,7 @@ DjangoContext.start_environment("sandbox.sandbox.settings")
@Vows.batch
class SettingsVows(DjangoContext):
class SettingsOverridingVows(DjangoContext):
class CannotSayHelloWithoutName(DjangoContext):
@ -24,11 +24,11 @@ class SettingsVows(DjangoContext):
with self.settings(SAY_HELLO_WITHOUT_NAME=False):
return self.get('/say/')
def should_be_ok(self, (topic, content)):
expect(topic.status).to_equal(200)
def should_be_ok(self, topic):
expect(topic.status_code).to_equal(200)
def should_ask_for_my_name(self, (topic, content)):
expect(content).to_equal("What's your name?")
def should_ask_for_my_name(self, topic):
expect(topic.content).to_equal("What's your name?")
class SayHelloWithoutName(DjangoContext):
@ -36,8 +36,8 @@ class SettingsVows(DjangoContext):
with self.settings(SAY_HELLO_WITHOUT_NAME=True):
return self.get('/say/')
def should_be_ok(self, (topic, content)):
expect(topic.status).to_equal(200)
def should_be_ok(self, topic):
expect(topic.status_code).to_equal(200)
def should_(self, (topic, content)):
expect(content).to_equal("Hello, guess!")
def should_(self, topic):
expect(topic.content).to_equal("Hello, guess!")