Django 1.8 support / Project revamp #13

Merged
rafaelcaricio merged 20 commits from django-1.8-support into master 2015-07-20 07:57:38 +00:00
Showing only changes of commit 61a25d0b9f - Show all commits

View file

@ -1,58 +1,52 @@
Django-Pyvows # Django-PyVows
=============
This project is an extension of pyVows to test [Django](https://www.djangoproject.com/) projects. It enables usage of core Django testing tools in a way that is in sync with pyVows workflow mindset.
Pyvows PyVows is a BDD (Behaviour Driven Development) inspired by Vows for node.js
-------
pyvows is a BDD (Behaviour Driven Development) inspired by Vows for node.js More documentation about pyVows can be found at [the project homepage](http://pyvows.org) or for mode updated usage check the project [tests itself](https://github.com/heynemann/pyvows/tree/master/tests).
More documentation about pyvows can be found at the project homepage Django-PyVows is in sync with the latest Django developments and supports Django 1.8.
http://pyvows.org ## Usage
Django-Pyvows There is no need to modify your project to use Django-PyVows. You only have to define where is your project settings module and start calling your project urls in your tests.
--------------
This project contains extensions to test Django projects under pyVows.
Using Django-Pyvows
-------------------
There is no need to modify your project to use Django-PyVows. You only have to create the vows
as you usually would, start the server and call your project urls:
```python ```python
from pyvows import Vows, expect from pyvows import Vows, expect
from django_pyvows.context import DjangoHTTPContext from django_pyvows.context import DjangoContext
@Vows.batch @Vows.batch
class ContextTest(DjangoHTTPContext): class SimpleTestVows(DjangoContext):
def setup(self): def settings_module(self):
self.start_server() return 'yourproject.settings'
def topic(self): def topic(self):
return self.get('/mygreaturl/') return self.get('/mygreaturl/')
def should_be_a_success(self, topic): def should_be_a_success(self, topic):
expect(topic.getcode()).to_equal(200) expect(topic.status_code).to_equal(200)
def should_return_the_correct_response_type(self, topic): def should_return_the_correct_response_type(self, topic):
expect(topic.headers.type).to_equal("text/html") expect(topic).contains("Welcome!")
``` ```
To work you only need to override the `get_settings` method from DjangoHTTPContext to The default `settings_module` is `settings` so you should define it accordly based on your `PYTHONPATH`.
return the path of your settings module. The default `get_settings` returns `"settings"`.
More info: https://github.com/rafaelcaricio/django-pyvows/wiki ### HTTP Client
External links We support `django.test.Client`, the methods `DjangoContext.get` and `DjangoContext.post` are actually simple wrappers around it so [the usage](https://docs.djangoproject.com/en/1.8/topics/testing/tools/#the-test-client) is the same.
--------------
- Asynchronous Testing with Django and PyVows ### Assertions
- http://www.realpython.com/blog/python/asynchronous-testing-with-django-and-pyvows/
- Unit Testing with pyVows and Django The available assertions in Django-PyVows are the same as in `django.test.SimpleTestCase` they were adapted to the context of BDD and PyVows.
- http://www.realpython.com/blog/python/unit-testing-with-pyvows-and-django/
- Integration testing with pyVows and Django - `contains`: reflects the `django.test.SimpleTestCase.assertContains`. Check usage at: [https://docs.djangoproject.com/en/1.8/topics/testing/tools/#django.test.SimpleTestCase.assertContains](https://docs.djangoproject.com/en/1.8/topics/testing/tools/#django.test.SimpleTestCase.assertContains)
- http://www.realpython.com/blog/python/integration-testing-with-pyvows-and-django/ - `redirects_to`: reflects the `django.test.SimpleTestCase.assertRedirects`. Check usage at: [https://docs.djangoproject.com/en/1.8/topics/testing/tools/#django.test.SimpleTestCase.assertRedirects](https://docs.djangoproject.com/en/1.8/topics/testing/tools/#django.test.SimpleTestCase.assertRedirects)
- `with_form_error`: reflects the `django.test.SimpleTestCase.assertFormError`. Check usage at: [https://docs.djangoproject.com/en/1.8/topics/testing/tools/#django.test.SimpleTestCase.assertFormError](https://docs.djangoproject.com/en/1.8/topics/testing/tools/#django.test.SimpleTestCase.assertFormError)
### Settings Override
TODO