django-admin-tools / admin_tools / dashboard / tests.py

from tempfile import mktemp
from unittest import TestCase
from django.test import TestCase as DjangoTestCase
from django.core import management
from django.contrib.auth import models as auth_models

from admin_tools.dashboard import AppIndexDashboard
from admin_tools.dashboard.modules import DashboardModule, Group

class ManagementCommandTest(DjangoTestCase):
    def test_customdashboard(self):
        # check that customdashboard command doesn't raise exceptions
        file_name = mktemp()
        management.call_command('customdashboard', file=file_name)
        # and fails if file is already here
        try:
            management.call_command('customdashboard', file=file_name)
            assert False
        except:
            pass

class AppIndexDashboardTest(TestCase):
    def test_models(self):
        models = ['django.contrib.auth.models.User',
                  'django.contrib.auth.models.Group']
        board = AppIndexDashboard('Auth', models)
        self.assertEqual(board.get_app_model_classes(),
                         [auth_models.User, auth_models.Group])

__test__ = {
    'DashboardModule.is_empty': DashboardModule.is_empty,
    'DashboardModule.render_css_classes': DashboardModule.render_css_classes,
    'Group.is_empty': Group.is_empty,
}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.