Skip to content

Commit

Permalink
Regression tests for #1475.
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanHayes committed Aug 3, 2016
1 parent c441384 commit f08ab24
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/core/tests/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -5190,3 +5190,39 @@ def test_unicode_exception(self, mock_sys):

args, kwargs = self.resource.error_response.call_args
self.assertEqual(kwargs['response_class'], http.HttpApplicationError)


class ModelDeclarativeMetaclassTestCase(TestCase):
"""
Regression tests for #1475
"""

def test__fields_and_queryset_specified__object_class_set(self):
class MyResource(ModelResource):
class Meta:
queryset = Note.objects.all()
fields = ['title']

resource = MyResource()
resource._meta.object_class = Note

def test__queryset_but_no_fields_specified__object_class_set(self):
class MyResource(ModelResource):
class Meta:
queryset = Note.objects.all()

resource = MyResource()
resource._meta.object_class = Note

def test__1475_example_resource(self):
class MyResource(ModelResource):
class Meta:
queryset = Note.objects.all()
fields = ['title']
allowed_methods = ['get']
resource_name = 'my_resource'
authentication = BasicAuthentication()
include_resource_uri = False

resource = MyResource()
resource._meta.object_class = Note

1 comment on commit f08ab24

@georgedorn
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the reason this doesn't replicate the bug is that it only happens when both queryset and object_class are unset. I believe this is not a bug, just a misleading error message - see #1517.

Please sign in to comment.