mirror of
https://github.com/jazzband/django-admin2.git
synced 2026-04-30 11:34:48 +00:00
27 lines
840 B
Python
27 lines
840 B
Python
from django.utils import unittest
|
|
from django.test.client import RequestFactory
|
|
|
|
|
|
from djadmin2 import apiviews
|
|
from ..models import Post
|
|
|
|
|
|
class ViewTest(unittest.TestCase):
|
|
def setUp(self):
|
|
self.factory = RequestFactory()
|
|
|
|
|
|
class IndexViewModelListCreateAPIViewTest(ViewTest):
|
|
|
|
def test_response_ok(self):
|
|
request = self.factory.get('/admin/api/blog/post/')
|
|
response = apiviews.ListCreateAPIView.as_view(model=Post)(request)
|
|
self.assertEqual(response.status_code, 200)
|
|
|
|
def test_list_includes_unicode_field(self):
|
|
Post.objects.create(title='Foo', body='Bar')
|
|
request = self.factory.get('/admin/api/blog/post/')
|
|
response = apiviews.ModelListCreateAPIView.as_view(model=Post)(request)
|
|
response.render()
|
|
|
|
self.assertIn('"unicode": "Foo"', response.content)
|