Skip to content

Commit

Permalink
Merge pull request #53 from brack3t/fix/tests
Browse files Browse the repository at this point in the history
Fix/tests
  • Loading branch information
kennethlove committed Jul 18, 2013
2 parents cf0ac83 + 6f4cb05 commit 642c3fa
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 67 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ install:
- "pip install -q django==$DJANGO_VERSION"
- "python setup.py -q install"
- "pip install -r requirements.txt"
script: "py.test tests/ --cov=braces --cov-report=html"
script: "py.test tests/"
matrix:
exclude:
- python: 3.3
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include README.rst
include README.md
include LICENSE
include CONTRIBUTORS.txt
recursive-include braces *.py
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# django-braces
Mixins for Django's class-based views.

[![Latest drone.io status](https://drone.io/github.com/brack3t/django-braces/status.png)](https://drone.io/github.com/brack3t/django-braces)
[![Latest PyPI version](https://pypip.in/v/django-braces/badge.png)](https://crate.io/packages/django-braces/)
[![Number of PyPI downloads](https://pypip.in/d/django-braces/badge.png)](https://crate.io/packages/django-braces/)

## Documentation
[Read The Docs](http://django-braces.readthedocs.org/en/latest/index.html)

## Installation
Install from PyPI with `pip`:
`pip install django-braces`

## Contributing

Fork, make a change, update the docs, add/update tests, make a pull request.

Add yourself to `CONTRIBUTORS.txt` if you want.

All development dependencies are available in `requirements.txt` file.

To run the test suite, execute the following in your shell (Django install is required):
`py.test tests/ --cov=braces --cov-report=html`

## Change Log


### 1.1.0
* `JSONResponseMixin.render_json_response` method updated to accept a status code.
* `JSONResponseMixin` added `json_dumps_kwargs` attribute & get method to pass args to the json encoder.
* New `OrderableListMixin` allows ordering of list views by GET params.
* Tests updated to test against latest stable Django release (1.5.1)
* Small fixes and additions to documentation.

### 1.0.0
* New 'abstract' `AccessMixin` which provides overridable `get_login_url` and `get_redirect_field_name methods` for all access-based mixins.
* Rewritten `LoginRequiredMixin` which provides same customization as other access mixins with `login_url`, `raise_exception` & `redirect_field_name`.
* New `PrefetchRelatedMixin`. Works the same as `SelectRelatedMixin` but uses Django's `prefetch_related` method.
* `CreateAndRedirectToEditView` is marked for deprecation.
* `PermissionRequiredMixin` no longer requires dot syntax for permission names.
* Marked package as supporting 2.6 thru 3.3 (from rafales).
* Fixes to documentation.
* Tests to cover new additions and changes.

### 0.2.3
* Tests for all mixins (from rafales).
* New `CsrfExemptMixin` for marking views as being CSRF exempt (from jarcoal).
* Some documentation updates and a spelling error correction (from shabda).
* `SuccessURLRedirectListMixin` raises `ImproperlyConfigured` if no `success_list_url` attribute is supplied (from kennethlove).

### 0.2.2
* Try importing the built-in json module first, drop back to Django if necessary. Django 1.5 compatibility.

### 0.2.1
* Fixed signature of `UserFormKwargsMixin.get_form_kwargs`
* Updated `JSONResponseMixin` to work with non-ASCII characters and other datatypes (such as datetimes)
* Fixed all mixins that have `raise_exception` as an argument to properly raise a `PermissionDenied` exception to allow for custom 403s.
54 changes: 0 additions & 54 deletions README.rst

This file was deleted.

6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@

# General information about the project.
project = u'django-braces'
copyright = u'2012, Kenneth Love and Chris Jones'
copyright = u'2013, Kenneth Love and Chris Jones'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '1.0.0'
version = '1.1.0'
# The full version, including alpha/beta/rc tags.
release = '1.0.0'
release = '1.1.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="django-braces",
version="1.0.0",
version="1.1.0",
description="Reusable, generic mixins for Django",
long_description="Mixins to add easy functionality to Django class-based views, forms, and models.",
keywords="django, views, forms, mixins",
Expand Down
2 changes: 1 addition & 1 deletion tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.contrib.auth.models import AnonymousUser


class TestViewHelper(test.TestCase):
class TestViewHelper(object):
"""
Helper class for unit-testing class based views.
"""
Expand Down
13 changes: 7 additions & 6 deletions tests/test_access_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,21 @@ def test_get_login_url_raises_exception(self):
ImproperlyConfigured.
"""
with self.assertRaises(ImproperlyConfigured):
self.dispatch_view(self.build_request(path=self.view_url),
login_url=None)
self.dispatch_view(
self.build_request(path=self.view_url), login_url=None)

def test_get_redirect_field_name_raises_exception(self):
"""
Test that get_redirect_field_name from AccessMixin raises
ImproperlyConfigured.
"""
with self.assertRaises(ImproperlyConfigured):
self.dispatch_view(self.build_request(path=self.view_url),
self.dispatch_view(
self.build_request(path=self.view_url),
redirect_field_name=None)


class TestLoginRequiredMixin(TestViewHelper):
class TestLoginRequiredMixin(TestViewHelper, test.TestCase):
"""
Tests for LoginRequiredMixin.
"""
Expand All @@ -108,8 +109,8 @@ def test_anonymous(self):

def test_anonymous_raises_exception(self):
with self.assertRaises(PermissionDenied):
self.dispatch_view(self.build_request(path=self.view_url),
raise_exception=True)
self.dispatch_view(
self.build_request(path=self.view_url), raise_exception=True)

def test_authenticated(self):
user = make_user()
Expand Down

0 comments on commit 642c3fa

Please sign in to comment.