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

View file

@ -2,27 +2,13 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
class RetrocompatibleResponse(object): def get(*args, **kwargs):
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):
from django.test.client import Client from django.test.client import Client
client = Client() client = Client()
resp = client.get(url) return client.get(*args, **kwargs)
return RetrocompatibleResponse(resp), resp.content
def post(url, data): def post(*args, **kwargs):
from django.test.client import Client from django.test.client import Client
client = 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 @Vows.batch
class SettingsVows(DjangoContext): class SettingsOverridingVows(DjangoContext):
class CannotSayHelloWithoutName(DjangoContext): class CannotSayHelloWithoutName(DjangoContext):
@ -24,11 +24,11 @@ class SettingsVows(DjangoContext):
with self.settings(SAY_HELLO_WITHOUT_NAME=False): with self.settings(SAY_HELLO_WITHOUT_NAME=False):
return self.get('/say/') return self.get('/say/')
def should_be_ok(self, (topic, content)): def should_be_ok(self, topic):
expect(topic.status).to_equal(200) expect(topic.status_code).to_equal(200)
def should_ask_for_my_name(self, (topic, content)): def should_ask_for_my_name(self, topic):
expect(content).to_equal("What's your name?") expect(topic.content).to_equal("What's your name?")
class SayHelloWithoutName(DjangoContext): class SayHelloWithoutName(DjangoContext):
@ -36,8 +36,8 @@ class SettingsVows(DjangoContext):
with self.settings(SAY_HELLO_WITHOUT_NAME=True): with self.settings(SAY_HELLO_WITHOUT_NAME=True):
return self.get('/say/') return self.get('/say/')
def should_be_ok(self, (topic, content)): def should_be_ok(self, topic):
expect(topic.status).to_equal(200) expect(topic.status_code).to_equal(200)
def should_(self, (topic, content)): def should_(self, topic):
expect(content).to_equal("Hello, guess!") expect(topic.content).to_equal("Hello, guess!")