예제 #1
0
파일: tests.py 프로젝트: pope1ni/django
 def test_custom_violation_error_message_clone(self):
     constraint = BaseConstraint(
         "base_name",
         violation_error_message="custom %(name)s message",
     ).clone()
     self.assertEqual(
         constraint.get_violation_error_message(),
         "custom base_name message",
     )
예제 #2
0
파일: tests.py 프로젝트: pope1ni/django
 def test_deconstruction(self):
     constraint = BaseConstraint(
         "base_name",
         violation_error_message="custom %(name)s message",
     )
     path, args, kwargs = constraint.deconstruct()
     self.assertEqual(path, "django.db.models.BaseConstraint")
     self.assertEqual(args, ())
     self.assertEqual(
         kwargs,
         {"name": "base_name", "violation_error_message": "custom %(name)s message"},
     )
예제 #3
0
파일: tests.py 프로젝트: GravyHands/django
 def test_constraint_sql(self):
     c = BaseConstraint('name')
     msg = 'This method must be implemented by a subclass.'
     with self.assertRaisesMessage(NotImplementedError, msg):
         c.constraint_sql(None, None)
예제 #4
0
 def test_remove_sql(self):
     c = BaseConstraint('name')
     msg = 'This method must be implemented by a subclass.'
     with self.assertRaisesMessage(NotImplementedError, msg):
         c.remove_sql(None, None)
예제 #5
0
 def test_contains_expressions(self):
     c = BaseConstraint('name')
     self.assertIs(c.contains_expressions, False)
예제 #6
0
 def test_create_sql(self):
     c = BaseConstraint("name")
     msg = "This method must be implemented by a subclass."
     with self.assertRaisesMessage(NotImplementedError, msg):
         c.create_sql(None, None)
예제 #7
0
파일: tests.py 프로젝트: pope1ni/django
 def test_default_violation_error_message(self):
     c = BaseConstraint("name")
     self.assertEqual(
         c.get_violation_error_message(), "Constraint “name” is violated."
     )