Skip to content

Commit

Permalink
Improved tests
Browse files Browse the repository at this point in the history
  • Loading branch information
qoda committed Oct 18, 2016
1 parent b7d506f commit 5c24ce6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
3 changes: 0 additions & 3 deletions navbuilder/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,3 @@ class Meta:
"title", "slug", "position", "menu", "parent", "target",
"link_content_type", "link_object_id"
]

def clean_parent(self):
pass
15 changes: 15 additions & 0 deletions navbuilder/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
from django.test import TestCase
from django.test.client import Client

from navbuilder.tests.test_base import load_fixtures


class AdminTestCase(TestCase):
def setUp(self):
load_fixtures(self)
self.client = Client()
self.editor = get_user_model().objects.create(
username="editor",
Expand All @@ -21,8 +24,20 @@ def test_admin(self):
self.assertEqual(response.status_code, 200)

def test_admin_menu(self):
response = self.client.get("/admin/navbuilder/menu/")
self.assertEqual(response.status_code, 200)

response = self.client.get("/admin/navbuilder/menu/add/")
self.assertEqual(response.status_code, 200)

def test_admin_menuitem(self):
response = self.client.get("/admin/navbuilder/menuitem/")
self.assertEqual(response.status_code, 200)
self.assertContains(response, self.menuitem.title)
self.assertContains(response, self.menuitem.link.get_absolute_url())

response = self.client.get("/admin/navbuilder/menuitem/add/")
self.assertEqual(response.status_code, 200)

def tearDown(self):
self.client.logout()
12 changes: 2 additions & 10 deletions navbuilder/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,18 @@ def setUp(self):
load_fixtures(self)

def test_link(self):

# ensure the data was saved correctly
for key, value in self.link_data.items():
self.assertEqual(getattr(self.link, key), value)

def test_menu(self):

# ensure the data was saved correctly
for key, value in self.menu_data.items():
self.assertEqual(getattr(self.menu, key), value)
self.assertEqual(unicode(self.menu), self.menu.title)

def test_menuitem(self):

# ensure the data was saved correctly
for key, value in self.menuitem_data.items():
self.assertEqual(getattr(self.menuitem, key), value)

# ensure the sub menu item data was saved correctly
for key, value in self.sub_menuitem_data.items():
self.assertEqual(getattr(self.sub_menuitem, key), value)

# ensure the parent menu item is accessible
self.assertEqual(self.sub_menuitem.parent, self.menuitem)
self.assertEqual(unicode(self.menuitem), self.menuitem.title)

0 comments on commit 5c24ce6

Please sign in to comment.