This repository has been archived on 2023-01-02. You can view files and clone it, but cannot push or open issues or pull requests.
django-pyvows/vows/settings_vows.py

49 lines
1.4 KiB
Python
Raw Normal View History

2011-08-22 20:06:54 +00:00
#!/usr/bin/python
# -*- 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 pyvows import Vows, expect
2015-07-18 21:25:24 +00:00
from django.test.utils import override_settings
2011-08-22 20:06:54 +00:00
2015-07-19 09:42:54 +00:00
from test_config import ConfiguredVowsContext as DjangoContext
2011-08-22 20:06:54 +00:00
@Vows.batch
2015-07-18 21:03:45 +00:00
class SettingsOverridingVows(DjangoContext):
2011-08-22 20:06:54 +00:00
2015-07-18 20:33:33 +00:00
class CannotSayHelloWithoutName(DjangoContext):
def topic(self):
2015-07-18 20:33:33 +00:00
with self.settings(SAY_HELLO_WITHOUT_NAME=False):
return self.get('/say/')
2011-08-22 20:06:54 +00:00
2015-07-18 21:03:45 +00:00
def should_be_ok(self, topic):
expect(topic.status_code).to_equal(200)
2011-08-22 20:06:54 +00:00
2015-07-18 21:03:45 +00:00
def should_ask_for_my_name(self, topic):
2015-07-19 10:25:39 +00:00
expect(topic).contains("What's your name?")
2011-08-22 20:06:54 +00:00
2015-07-18 20:33:33 +00:00
class SayHelloWithoutName(DjangoContext):
2011-08-22 20:06:54 +00:00
def topic(self):
2015-07-18 20:33:33 +00:00
with self.settings(SAY_HELLO_WITHOUT_NAME=True):
return self.get('/say/')
2011-08-22 20:06:54 +00:00
2015-07-18 21:03:45 +00:00
def should_be_ok(self, topic):
expect(topic.status_code).to_equal(200)
2011-08-22 20:06:54 +00:00
2015-07-18 21:03:45 +00:00
def should_(self, topic):
2015-07-19 10:25:39 +00:00
expect(topic).contains("Hello, guest!")
2015-07-18 21:25:24 +00:00
class UseDecoratorToChangeSettings(DjangoContext):
@override_settings(SAY_HELLO_WITHOUT_NAME=True)
def topic(self):
return self.get('/say/')
def should_say_hello_to_guest(self, topic):
2015-07-19 10:25:39 +00:00
expect(topic).contains("Hello, guest!")