mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-11 04:07:39 +03:00
lookup_type is deprecated in favor of lookup_expr (#4259)
* lookup_type is deprecated in favor of lookup_expr * assertEquals is deprecated in favor of assertEqual * app_name is a required keyword as of Django 1.10
This commit is contained in:
parent
549210b50f
commit
6defb8da47
|
@ -178,8 +178,8 @@ For more advanced filtering requirements you can specify a `FilterSet` class tha
|
||||||
from rest_framework import generics
|
from rest_framework import generics
|
||||||
|
|
||||||
class ProductFilter(filters.FilterSet):
|
class ProductFilter(filters.FilterSet):
|
||||||
min_price = django_filters.NumberFilter(name="price", lookup_type='gte')
|
min_price = django_filters.NumberFilter(name="price", lookup_expr='gte')
|
||||||
max_price = django_filters.NumberFilter(name="price", lookup_type='lte')
|
max_price = django_filters.NumberFilter(name="price", lookup_expr='lte')
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Product
|
model = Product
|
||||||
fields = ['category', 'in_stock', 'min_price', 'max_price']
|
fields = ['category', 'in_stock', 'min_price', 'max_price']
|
||||||
|
|
|
@ -37,9 +37,9 @@ if django_filters:
|
||||||
|
|
||||||
# These class are used to test a filter class.
|
# These class are used to test a filter class.
|
||||||
class SeveralFieldsFilter(django_filters.FilterSet):
|
class SeveralFieldsFilter(django_filters.FilterSet):
|
||||||
text = django_filters.CharFilter(lookup_type='icontains')
|
text = django_filters.CharFilter(lookup_expr='icontains')
|
||||||
decimal = django_filters.NumberFilter(lookup_type='lt')
|
decimal = django_filters.NumberFilter(lookup_expr='lt')
|
||||||
date = django_filters.DateFilter(lookup_type='gt')
|
date = django_filters.DateFilter(lookup_expr='gt')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = FilterableItem
|
model = FilterableItem
|
||||||
|
@ -53,7 +53,7 @@ if django_filters:
|
||||||
|
|
||||||
# These classes are used to test a misconfigured filter class.
|
# These classes are used to test a misconfigured filter class.
|
||||||
class MisconfiguredFilter(django_filters.FilterSet):
|
class MisconfiguredFilter(django_filters.FilterSet):
|
||||||
text = django_filters.CharFilter(lookup_type='icontains')
|
text = django_filters.CharFilter(lookup_expr='icontains')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = BasicModel
|
model = BasicModel
|
||||||
|
|
|
@ -377,7 +377,7 @@ class TestGenericIPAddressFieldValidation(TestCase):
|
||||||
|
|
||||||
s = TestSerializer(data={'address': 'not an ip address'})
|
s = TestSerializer(data={'address': 'not an ip address'})
|
||||||
self.assertFalse(s.is_valid())
|
self.assertFalse(s.is_valid())
|
||||||
self.assertEquals(1, len(s.errors['address']),
|
self.assertEqual(1, len(s.errors['address']),
|
||||||
'Unexpected number of validation errors: '
|
'Unexpected number of validation errors: '
|
||||||
'{0}'.format(s.errors))
|
'{0}'.format(s.errors))
|
||||||
|
|
||||||
|
|
|
@ -286,14 +286,14 @@ class JSONRendererTests(TestCase):
|
||||||
qs = DummyTestModel.objects.values('id', 'name')
|
qs = DummyTestModel.objects.values('id', 'name')
|
||||||
ret = JSONRenderer().render(qs)
|
ret = JSONRenderer().render(qs)
|
||||||
data = json.loads(ret.decode('utf-8'))
|
data = json.loads(ret.decode('utf-8'))
|
||||||
self.assertEquals(data, [{'id': o.id, 'name': o.name}])
|
self.assertEqual(data, [{'id': o.id, 'name': o.name}])
|
||||||
|
|
||||||
def test_render_queryset_values_list(self):
|
def test_render_queryset_values_list(self):
|
||||||
o = DummyTestModel.objects.create(name='dummy')
|
o = DummyTestModel.objects.create(name='dummy')
|
||||||
qs = DummyTestModel.objects.values_list('id', 'name')
|
qs = DummyTestModel.objects.values_list('id', 'name')
|
||||||
ret = JSONRenderer().render(qs)
|
ret = JSONRenderer().render(qs)
|
||||||
data = json.loads(ret.decode('utf-8'))
|
data = json.loads(ret.decode('utf-8'))
|
||||||
self.assertEquals(data, [[o.id, o.name]])
|
self.assertEqual(data, [[o.id, o.name]])
|
||||||
|
|
||||||
def test_render_dict_abc_obj(self):
|
def test_render_dict_abc_obj(self):
|
||||||
class Dict(MutableMapping):
|
class Dict(MutableMapping):
|
||||||
|
@ -323,7 +323,7 @@ class JSONRendererTests(TestCase):
|
||||||
x[2] = 3
|
x[2] = 3
|
||||||
ret = JSONRenderer().render(x)
|
ret = JSONRenderer().render(x)
|
||||||
data = json.loads(ret.decode('utf-8'))
|
data = json.loads(ret.decode('utf-8'))
|
||||||
self.assertEquals(data, {'key': 'string value', '2': 3})
|
self.assertEqual(data, {'key': 'string value', '2': 3})
|
||||||
|
|
||||||
def test_render_obj_with_getitem(self):
|
def test_render_obj_with_getitem(self):
|
||||||
class DictLike(object):
|
class DictLike(object):
|
||||||
|
|
|
@ -305,8 +305,8 @@ class TestNamespaceVersioningHyperlinkedRelatedFieldScheme(URLPatternsTestCase):
|
||||||
]
|
]
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^v1/', include(included, namespace='v1')),
|
url(r'^v1/', include(included, namespace='v1', app_name='restframeworkv1')),
|
||||||
url(r'^v2/', include(included, namespace='v2')),
|
url(r'^v2/', include(included, namespace='v2', app_name='restframeworkv2')),
|
||||||
url(r'^non-api/(?P<pk>\d+)/$', dummy_pk_view, name='non-api-view')
|
url(r'^non-api/(?P<pk>\d+)/$', dummy_pk_view, name='non-api-view')
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ class WriteOnlyFieldTests(TestCase):
|
||||||
}
|
}
|
||||||
serializer = self.Serializer(data=data)
|
serializer = self.Serializer(data=data)
|
||||||
self.assertTrue(serializer.is_valid())
|
self.assertTrue(serializer.is_valid())
|
||||||
self.assertEquals(serializer.validated_data, data)
|
self.assertEqual(serializer.validated_data, data)
|
||||||
|
|
||||||
def write_only_fields_are_not_present_on_output(self):
|
def write_only_fields_are_not_present_on_output(self):
|
||||||
instance = {
|
instance = {
|
||||||
|
@ -29,4 +29,4 @@ class WriteOnlyFieldTests(TestCase):
|
||||||
'password': '123'
|
'password': '123'
|
||||||
}
|
}
|
||||||
serializer = self.Serializer(instance)
|
serializer = self.Serializer(instance)
|
||||||
self.assertEquals(serializer.data, {'email': 'foo@example.com'})
|
self.assertEqual(serializer.data, {'email': 'foo@example.com'})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user