From 2c2ac888d0d8b525ed6f687d60a14f4a5d01dbcc Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Sun, 7 Feb 2016 15:33:40 +0000 Subject: [PATCH] Updated the API tests to avoid deprecation warnings from a new version of Tastypie (0.13.1). - Legacy-Id: 10796 --- ietf/api/tests.py | 8 ++++---- ietf/utils/tests_restapi.py | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ietf/api/tests.py b/ietf/api/tests.py index 620b18863..abac94b99 100644 --- a/ietf/api/tests.py +++ b/ietf/api/tests.py @@ -2,13 +2,13 @@ import os import sys import json -from django.test import Client +from django.test import Client, TestCase from django.conf import settings from django.utils.importlib import import_module from django.db import models from tastypie.exceptions import BadRequest -from tastypie.test import ResourceTestCase +from tastypie.test import ResourceTestCaseMixin import debug # pyflakes:ignore @@ -18,7 +18,7 @@ OMITTED_APPS = ( 'ietf.ipr', ) -class TastypieApiTestCase(ResourceTestCase): +class TastypieApiTestCase(ResourceTestCaseMixin, TestCase): def __init__(self, *args, **kwargs): self.apps = {} for app_name in settings.INSTALLED_APPS: @@ -28,7 +28,7 @@ class TastypieApiTestCase(ResourceTestCase): models_path = os.path.join(os.path.dirname(app.__file__), "models.py") if os.path.exists(models_path): self.apps[name] = app - super(ResourceTestCase, self).__init__(*args, **kwargs) + super(TastypieApiTestCase, self).__init__(*args, **kwargs) def test_api_top_level(self): client = Client(Accept='application/json') diff --git a/ietf/utils/tests_restapi.py b/ietf/utils/tests_restapi.py index 6da7812a8..57dc4f6a3 100644 --- a/ietf/utils/tests_restapi.py +++ b/ietf/utils/tests_restapi.py @@ -4,12 +4,13 @@ import debug debug.debug = True from django.core.urlresolvers import reverse +from django.test import TestCase -from tastypie.test import ResourceTestCase +from tastypie.test import ResourceTestCaseMixin from ietf.utils.test_data import make_test_data -class RestApi(ResourceTestCase): +class RestApi(ResourceTestCaseMixin, TestCase): def list_recursively(self, resource, format): """ Recurse down all the app trees, retrieving all the data available. This ensures @@ -74,4 +75,4 @@ class RestApi(ResourceTestCase): value = doc[key] if isinstance(value, basestring) and value.startswith('%s/'%apitop): self.api_client.get(value, format='json') - \ No newline at end of file +