diff options
| author | Tom Christie | 2014-09-11 21:48:54 +0100 |
|---|---|---|
| committer | Tom Christie | 2014-09-11 21:48:54 +0100 |
| commit | 040bfcc09c851bb3dadd60558c78a1f7937e9fbd (patch) | |
| tree | 4af85b2ee317528a080422e5893cc01fae079dcb /tests | |
| parent | a7518719917c7ad8e699119b442cfeb568ba1dde (diff) | |
| download | django-rest-framework-040bfcc09c851bb3dadd60558c78a1f7937e9fbd.tar.bz2 | |
NotImplemented stubs for Field, and DecimalField improvements
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_filters.py | 10 | ||||
| -rw-r--r-- | tests/test_pagination.py | 4 |
2 files changed, 7 insertions, 7 deletions
diff --git a/tests/test_filters.py b/tests/test_filters.py index 300e47e4..01668114 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -102,7 +102,7 @@ if django_filters: class CommonFilteringTestCase(TestCase): def _serialize_object(self, obj): - return {'id': obj.id, 'text': obj.text, 'decimal': obj.decimal, 'date': obj.date} + return {'id': obj.id, 'text': obj.text, 'decimal': str(obj.decimal), 'date': obj.date} def setUp(self): """ @@ -145,7 +145,7 @@ class IntegrationTestFiltering(CommonFilteringTestCase): request = factory.get('/', {'decimal': '%s' % search_decimal}) response = view(request).render() self.assertEqual(response.status_code, status.HTTP_200_OK) - expected_data = [f for f in self.data if f['decimal'] == search_decimal] + expected_data = [f for f in self.data if Decimal(f['decimal']) == search_decimal] self.assertEqual(response.data, expected_data) # Tests that the date filter works. @@ -168,7 +168,7 @@ class IntegrationTestFiltering(CommonFilteringTestCase): request = factory.get('/', {'decimal': '%s' % search_decimal}) response = view(request).render() self.assertEqual(response.status_code, status.HTTP_200_OK) - expected_data = [f for f in self.data if f['decimal'] == search_decimal] + expected_data = [f for f in self.data if Decimal(f['decimal']) == search_decimal] self.assertEqual(response.data, expected_data) @unittest.skipUnless(django_filters, 'django-filter not installed') @@ -201,7 +201,7 @@ class IntegrationTestFiltering(CommonFilteringTestCase): request = factory.get('/', {'decimal': '%s' % search_decimal}) response = view(request).render() self.assertEqual(response.status_code, status.HTTP_200_OK) - expected_data = [f for f in self.data if f['decimal'] < search_decimal] + expected_data = [f for f in self.data if Decimal(f['decimal']) < search_decimal] self.assertEqual(response.data, expected_data) # Tests that the date filter set with 'gt' in the filter class works. @@ -230,7 +230,7 @@ class IntegrationTestFiltering(CommonFilteringTestCase): response = view(request).render() self.assertEqual(response.status_code, status.HTTP_200_OK) expected_data = [f for f in self.data if f['date'] > search_date and - f['decimal'] < search_decimal] + Decimal(f['decimal']) < search_decimal] self.assertEqual(response.data, expected_data) @unittest.skipUnless(django_filters, 'django-filter not installed') diff --git a/tests/test_pagination.py b/tests/test_pagination.py index 68983ba2..a7f8e691 100644 --- a/tests/test_pagination.py +++ b/tests/test_pagination.py @@ -135,7 +135,7 @@ class IntegrationTestPaginationAndFiltering(TestCase): self.objects = FilterableItem.objects self.data = [ - {'id': obj.id, 'text': obj.text, 'decimal': obj.decimal, 'date': obj.date} + {'id': obj.id, 'text': obj.text, 'decimal': str(obj.decimal), 'date': obj.date} for obj in self.objects.all() ] @@ -381,7 +381,7 @@ class TestMaxPaginateByParam(TestCase): # Tests for context in pagination serializers -class CustomField(serializers.Field): +class CustomField(serializers.ReadOnlyField): def to_native(self, value): if 'view' not in self.context: raise RuntimeError("context isn't getting passed into custom field") |
