mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-24 08:14:16 +03:00
971578ca34
* Get rid of runtests.py * Moved test code from rest_framework/tests and rest_framework/runtests to tests * Invoke py.test from setup.py * Invoke py.test from Travis * Invoke py.test from tox * Changed setUpClass to be just plain setUp in test_permissions.py * Updated contribution guideline to show how to invoke py.test
29 lines
966 B
Python
29 lines
966 B
Python
from django.db import models
|
|
from django.test import TestCase
|
|
|
|
from rest_framework.serializers import _resolve_model
|
|
from tests.models import BasicModel
|
|
|
|
|
|
class ResolveModelTests(TestCase):
|
|
"""
|
|
`_resolve_model` should return a Django model class given the
|
|
provided argument is a Django model class itself, or a properly
|
|
formatted string representation of one.
|
|
"""
|
|
def test_resolve_django_model(self):
|
|
resolved_model = _resolve_model(BasicModel)
|
|
self.assertEqual(resolved_model, BasicModel)
|
|
|
|
def test_resolve_string_representation(self):
|
|
resolved_model = _resolve_model('tests.BasicModel')
|
|
self.assertEqual(resolved_model, BasicModel)
|
|
|
|
def test_resolve_non_django_model(self):
|
|
with self.assertRaises(ValueError):
|
|
_resolve_model(TestCase)
|
|
|
|
def test_resolve_improper_string_representation(self):
|
|
with self.assertRaises(ValueError):
|
|
_resolve_model('BasicModel')
|