Commit 8b991346 by Alex Gaynor

Add tests for trunk, and start fixing them.

parent 1563a6b3
...@@ -130,6 +130,11 @@ class TaggableManager(RelatedField): ...@@ -130,6 +130,11 @@ class TaggableManager(RelatedField):
return [("%s__content_type" % prefix, cts[0])] return [("%s__content_type" % prefix, cts[0])]
return [("%s__content_type__in" % prefix, cts)] return [("%s__content_type__in" % prefix, cts)]
def bulk_related_objects(self, new_objs, using):
return self.through._base_manager.db_manager(using).filter(
**self.through.bulk_lookup_kwargs(new_objs)
)
class _TaggableManager(models.Manager): class _TaggableManager(models.Manager):
def __init__(self, through, model, instance): def __init__(self, through, model, instance):
......
...@@ -82,6 +82,12 @@ class ItemBase(models.Model): ...@@ -82,6 +82,12 @@ class ItemBase(models.Model):
'content_object': instance 'content_object': instance
} }
@classmethod
def bulk_lookup_kwargs(cls, instances):
return {
"content_object__in": instances,
}
class TaggedItemBase(ItemBase): class TaggedItemBase(ItemBase):
if django.VERSION < (1, 2): if django.VERSION < (1, 2):
...@@ -130,6 +136,14 @@ class GenericTaggedItemBase(ItemBase): ...@@ -130,6 +136,14 @@ class GenericTaggedItemBase(ItemBase):
} }
@classmethod @classmethod
def bulk_lookup_kwargs(cls, instances):
# TODO: instances[0], can we assume there are instances.
return {
"object_id__in": [instance.pk for instance in instances],
"content_type": ContentType.objects.get_for_model(instances[0]),
}
@classmethod
def tags_for(cls, model, instance=None): def tags_for(cls, model, instance=None):
ct = ContentType.objects.get_for_model(model) ct = ContentType.objects.get_for_model(model)
kwargs = { kwargs = {
......
[tox] [tox]
envlist = py25,py26,py27,pypy envlist = py25, py26 , py27, pypy, py25-trunk, py26-trunk, py27-trunk, pypy-trunk
[testenv] [testenv]
commands = python setup.py test commands = python setup.py test
deps = deps =
django django==1.2.3
[testenv:py25-trunk]
basepython = python2.5
deps =
http://www.djangoproject.com/download/1.3-alpha-1/tarball/
[testenv:py26-trunk]
basepython = python2.6
deps =
http://www.djangoproject.com/download/1.3-alpha-1/tarball/
[testenv:py27-trunk]
basepython = python2.7
deps =
http://www.djangoproject.com/download/1.3-alpha-1/tarball/
[testenv:pypy-trunk]
basepython = pypy
deps =
http://www.djangoproject.com/download/1.3-alpha-1/tarball/
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment