Updated the API tests to avoid deprecation warnings from a new version of Tastypie (0.13.1).
- Legacy-Id: 10796
This commit is contained in:
parent
49defdba40
commit
2c2ac888d0
|
@ -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')
|
||||
|
|
|
@ -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')
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue