ccdb-api/ccdb/utils/tests/test_models.py
Matthew Dillon 910d3b4beb Admin Section API (#11)
Models for managing admin pages
2016-09-05 17:03:01 -07:00

26 lines
911 B
Python

from django.test import TestCase
from django.test.client import RequestFactory
from ..models import AdminSection, AdminEntry
from .factories import AdminSectionFactory, AdminEntryFactory
class AdminSectionTestCase(TestCase):
def test_creation(self):
a = AdminSectionFactory()
self.assertTrue(isinstance(a, AdminSection))
self.assertEqual(a.__str__(), a.name)
class AdminEntryTestCase(TestCase):
def test_creation(self):
a = AdminEntryFactory()
self.assertTrue(isinstance(a, AdminEntry))
self.assertEqual(a.__str__(), "%s %s" % (a.package, a.model))
def test_admin_url(self):
a = AdminEntryFactory(package='utils', model='adminentry')
request_factory = RequestFactory()
request = request_factory.get('/')
self.assertEqual('http://testserver/admin/utils/adminentry/',
a.admin_url(request))