40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
#!/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
|
|
|
|
from django_pyvows.context import DjangoContext
|
|
|
|
DjangoContext.start_environment("sandbox.sandbox.settings")
|
|
|
|
|
|
@Vows.batch
|
|
class DjangoAssertionsVows(DjangoContext):
|
|
|
|
class RedirectsTo(DjangoContext):
|
|
def topic(self):
|
|
return self.get("/say")
|
|
|
|
def should_redirect(self, topic):
|
|
expect(topic).redirects_to('/say/', status_code=301)
|
|
|
|
class Contains(DjangoContext):
|
|
def topic(self):
|
|
return self.get('/say/')
|
|
|
|
def should_work(self, topic):
|
|
expect(topic).contains('name')
|
|
|
|
class WithFormError(DjangoContext):
|
|
def topic(self):
|
|
return self.post('/post-name/', {'another_field': 'filled'})
|
|
|
|
def should_work(self, topic):
|
|
expect(topic).with_form_error('form', 'your_name', 'This field is required.')
|