Skip to content

Commit

Permalink
Merge pull request #15 from texastribune/bleeding-edge
Browse files Browse the repository at this point in the history
Extend to Django 1.7b1 and Python 3.4
  • Loading branch information
crccheck committed May 28, 2014
2 parents a212beb + e2b955c commit 2e15ba2
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@ env:
- TOX_ENV=py27django15
- TOX_ENV=py27django16
- TOX_ENV=py33django16
- TOX_ENV=py27django17
- TOX_ENV=py33django17
- TOX_ENV=py34django16
- TOX_ENV=py34django17
install: "pip install tox"
script: tox -e $TOX_ENV
20 changes: 20 additions & 0 deletions django_object_actions/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.db.models.query import QuerySet
from django.test import TestCase
from django.utils.unittest import expectedFailure

from example_project.polls.models import Poll

Expand Down Expand Up @@ -80,6 +81,25 @@ def test_can_turn_object_into_queryset(self):
self.assertEqual(qs.filter().get(), self.obj)
self.assertEqual(qs.latest('bar'), self.obj)

def test_queryset_supports_delete(self):
qs = QuerySetIsh(self.obj)
qs.delete()
with self.assertRaises(Poll.DoesNotExist):
Poll.objects.get(pk=1)

@expectedFailure
def test_queryset_supports_filter(self):
# yeah, we don't actually support doing this, but it would be nice.
qs = QuerySetIsh(self.obj)
with self.assertRaises(Poll.DoesNotExist):
# this should be empty because the question is just `"hi"`
qs.filter(question='abra cadabra').get()

def test_queryset_supports_update(self):
qs = QuerySetIsh(self.obj)
qs.update(question='mooo')
self.assertEqual(Poll.objects.get(pk=1).question, 'mooo')


class DecoratorTest(TestCase):
def setUp(self):
Expand Down
7 changes: 7 additions & 0 deletions django_object_actions/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,20 @@ def __init__(self, instance=None, *args, **kwargs):
# Django 1.5 does this instead, getting the model may be overkill
# we may be able to throw away all this logic
model = instance._meta.concrete_model
self._doa_instance = instance
super(QuerySetIsh, self).__init__(model, *args, **kwargs)
self._result_cache = [instance]

def _clone(self, *args, **kwargs):
# don't clone me, bro
return self

def get(self, *args, **kwargs):
# Starting in Django 1.7, `QuerySet.get` started slicing to
# `MAX_GET_RESULTS`, so to avoid messing with `__getslice__`, override
# `.get`.
return self._doa_instance


def takes_instance_or_queryset(func):
"""Decorator that makes standard actions compatible."""
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ django-nose
ipython
ipdb
ipdbplugin
tox==1.6.1
tox==1.7.1
28 changes: 28 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ envlist =
py27django15,
py27django16,
py33django16,
py27django17,
py33django17,
py34django16,
py34django17,

downloadcache = {toxworkdir}/.cache

Expand Down Expand Up @@ -56,3 +60,27 @@ basepython=python3.3
deps =
{[testenv]deps}
django>=1.6,>1.5

[testenv:py27django17]
basepython=python2.7
deps =
{[testenv]deps}
https://www.djangoproject.com/download/1.7b3/tarball/

[testenv:py33django17]
basepython=python3.3
deps =
{[testenv]deps}
https://www.djangoproject.com/download/1.7b3/tarball/

[testenv:py34django16]
basepython=python3.4
deps =
{[testenv]deps}
django>=1.6,>1.5

[testenv:py34django17]
basepython=python3.4
deps =
{[testenv]deps}
https://www.djangoproject.com/download/1.7b3/tarball/

0 comments on commit 2e15ba2

Please sign in to comment.