Added tests for custom menu and dashboard media

This commit is contained in:
David Jean Louis 2015-07-07 10:41:21 +02:00
parent 5bda74f00b
commit 6891e59fc3
7 changed files with 31 additions and 0 deletions

View File

@ -12,6 +12,12 @@ class CustomIndexDashboard(Dashboard):
"""
Custom index dashboard for test_proj.
"""
class Media:
css = {
'all': ('test_app/dashboard.css',),
}
js = ('test_app/dashboard.js',)
def __init__(self, **kwargs):
Dashboard.__init__(self, **kwargs)

View File

@ -10,6 +10,12 @@ class CustomMenu(Menu):
"""
Custom Menu for test_proj admin site.
"""
class Media:
css = {
'all': ('test_app/menu.css',),
}
js = ('test_app/menu.js',)
def __init__(self, **kwargs):
Menu.__init__(self, **kwargs)
self.children += [

View File

@ -0,0 +1 @@
/* dummy file for testing purpose */

View File

@ -0,0 +1 @@
// dummy file for testing purpose

View File

@ -0,0 +1 @@
/* dummy file for testing purpose */

View File

@ -0,0 +1 @@
// dummy file for testing purpose

View File

@ -13,6 +13,21 @@ class AdminBasicTest(TestCase):
self.assertEqual(response.status_code, 200)
self.client.logout()
def test_custom_menu_media(self):
self.client.login(username='superuser', password='123')
response = self.client.get('/admin/')
self.assertContains(response, '<link rel="stylesheet" href="/static/test_app/menu.css" type="text/css" media="all"/>')
self.assertContains(response, '/static/test_app/menu.js')
self.client.logout()
def test_custom_dashboard_media(self):
self.client.login(username='superuser', password='123')
response = self.client.get('/admin/')
self.assertContains(response, '<link rel="stylesheet" href="/static/test_app/dashboard.css" type="text/css" media="all"/>')
self.assertContains(response, '/static/test_app/dashboard.js')
self.client.logout()
def test_permissions(self):
self.client.login(username='staff', password='123')
index = self.client.get('/admin/')