Example #1
0
 def test_mainmenuitem_clean_missing_link_url(self):
     menu = MainMenu.objects.get(pk=1)
     new_item = MainMenuItem(menu=menu)
     self.assertRaisesMessage(
         ValidationError,
         "Please choose an internal page or provide a custom URL",
         new_item.clean)
Example #2
0
 def test_mainmenuitem_clean_missing_link_text(self):
     menu = MainMenu.objects.get(pk=1)
     new_item = MainMenuItem(menu=menu, link_url='test/')
     self.assertRaisesMessage(
         ValidationError,
         "This field is required when linking to a custom URL",
         new_item.clean)
Example #3
0
 def test_mainmenuitem_clean_missing_link_url(self):
     menu = MainMenu.objects.get(pk=1)
     new_item = MainMenuItem(menu=menu)
     self.assertRaisesMessage(
         ValidationError,
         "This must be set if you're not linking to a page.",
         new_item.clean)
Example #4
0
 def test_mainmenuitem_clean_missing_link_text(self):
     menu = MainMenu.objects.get(pk=1)
     new_item = MainMenuItem(menu=menu, link_url='test/')
     self.assertRaisesMessage(
         ValidationError,
         "This must be set if you're linking to a custom URL.",
         new_item.clean)
Example #5
0
 def test_mainmenuitem_clean_link_url_and_link_page(self):
     menu = MainMenu.objects.get(pk=1)
     new_item = MainMenuItem(menu=menu,
                             link_text='Test',
                             link_url='test/',
                             link_page=Page.objects.get(pk=6))
     self.assertRaisesMessage(
         ValidationError,
         "Linking to both a page and custom URL is not permitted",
         new_item.clean)
Example #6
0
 def test_mainmenuitem_clean_link_url_and_link_page(self):
     menu = MainMenu.objects.get(pk=1)
     new_item = MainMenuItem(menu=menu,
                             link_text='Test',
                             link_url='test/',
                             link_page=Page.objects.get(pk=6))
     self.assertRaisesMessage(
         ValidationError,
         "You cannot link to both a page and URL. Please review your link and clear any unwanted values.",
         new_item.clean)