def test_duplicate_value_raises_exception(self):
        order = ['posted', '-posted']
        with patch.object(settings, 'COMMENT_ORDER_BY', order):
            with self.assertRaises(ImproperlyConfigured) as error:
                _validate_order()

        exception = error.exception

        self.assertIsInstance(exception, ImproperlyConfigured)
        self.assertIs(order[0] in str(exception), True)
示例#2
0
 def _filter_parents(qs, parent=None):
     return qs.filter(parent=parent).order_by(*_validate_order())
 def test_success(self):
     order = ['-reaction__likes']
     with patch.object(settings, 'COMMENT_ORDER_BY', order):
         self.assertEqual(_validate_order(), order)