コード例 #1
0
ファイル: tests.py プロジェクト: Belgabor/django
 def test_explicitpk_unique(self):
     """Ensure keys and blank character strings are tested for uniqueness."""
     form = ExplicitPKForm({'key': u'key1', 'desc': u''})
     self.assertTrue(form.is_valid())
     form.save()
     form = ExplicitPKForm({'key': u'key1', 'desc': u''})
     self.assertFalse(form.is_valid())
     self.assertEqual(len(form.errors), 3)
     self.assertEqual(form.errors['__all__'], [u'Explicit pk with this Key and Desc already exists.'])
     self.assertEqual(form.errors['desc'], [u'Explicit pk with this Desc already exists.'])
     self.assertEqual(form.errors['key'], [u'Explicit pk with this Key already exists.'])
コード例 #2
0
 def test_explicitpk_unique(self):
     """Ensure keys and blank character strings are tested for uniqueness."""
     form = ExplicitPKForm({"key": u"key1", "desc": u""})
     self.assertTrue(form.is_valid())
     form.save()
     form = ExplicitPKForm({"key": u"key1", "desc": u""})
     self.assertFalse(form.is_valid())
     self.assertEqual(len(form.errors), 3)
     self.assertEqual(form.errors["__all__"], [u"Explicit pk with this Key and Desc already exists."])
     self.assertEqual(form.errors["desc"], [u"Explicit pk with this Desc already exists."])
     self.assertEqual(form.errors["key"], [u"Explicit pk with this Key already exists."])
コード例 #3
0
ファイル: tests.py プロジェクト: Belgabor/django
 def test_explicitpk_unspecified(self):
     """Test for primary_key being in the form and failing validation."""
     form = ExplicitPKForm({'key': u'', 'desc': u'' })
     self.assertFalse(form.is_valid())