Пример #1
0
 def test_clean_no_base_url(self):
     h = HierarchyFactory()
     f = CloneHierarchyForm({
         'name': 'new name',
         'base_url': '',
     }, instance=h)
     self.assertTrue(f.is_valid())
     new_hier = f.save()
     self.assertEqual(new_hier.name, 'new name')
     self.assertEqual(new_hier.base_url, 'new-name')
Пример #2
0
 def test_clean_prevents_duplicate_base_url(self):
     h = HierarchyFactory()
     f = CloneHierarchyForm({
         'name': 'new name',
         'base_url': h.base_url,
     }, instance=h)
     self.assertFalse(f.is_valid())
     self.assertEqual(f.errors, {
         '__all__': [
             u"There's already a hierarchy with the base_url: /pages/"]
     })
Пример #3
0
 def test_init(self):
     h = HierarchyFactory()
     CloneHierarchyForm(instance=h)