Skip to content

Commit

Permalink
Isolate failing assertion in separate test
Browse files Browse the repository at this point in the history
  • Loading branch information
georgedorn committed Aug 6, 2018
1 parent 53aed4b commit 07dfec5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tests/core/tests/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -2102,13 +2102,19 @@ def test_build_filters(self):
resource_4 = AnotherSubjectResource()
self.assertEqual(resource_4.build_filters(filters={'notes__user__startswith': 'Daniel'}), {'notes__author__startswith': 'Daniel'})

# Make sure that fields that don't have attributes can't be filtered on.
self.assertRaises(InvalidFilterError, resource_4.build_filters, filters={'notes__hello_world': 'News'})

# Make sure build_filters works even on resources without queryset
resource = NoQuerysetNoteResource()
self.assertEqual(resource.build_filters(), {})

def test_build_filters_bad(self):
"""
Test that a nonsensical filter fails validation.
"""
resource = AnotherSubjectResource()
# Make sure that fields that don't have attributes can't be filtered on.
self.assertRaises(InvalidFilterError, resource.build_filters, filters={'notes__hello_world': 'News'})


def test_custom_build_filters(self):
"""
A test derived from an example in the documentation (under Advanced Filtering).
Expand Down

0 comments on commit 07dfec5

Please sign in to comment.