Пример #1
0
 def test_format_checker_failed(self):
     format_checker = validators.FormatChecker()
     exc = self.assertRaises(jsonschema_exc.FormatError,
                             format_checker.check, "   ", "name")
     self.assertIsInstance(exc.cause, exception.InvalidName)
     self.assertEqual(
         "An invalid 'name' value was provided. The name must "
         "be: printable characters. "
         "Can not start or end with whitespace.",
         exc.cause.format_message())
Пример #2
0
    def test_format_checker_failed_with_non_string(self):
        checks = ["name"]
        format_checker = validators.FormatChecker()

        for check in checks:
            exc = self.assertRaises(jsonschema_exc.FormatError,
                                    format_checker.check, None, "name")
            self.assertIsInstance(exc.cause, exception.InvalidName)
            self.assertEqual(
                "An invalid 'name' value was provided. The name "
                "must be: printable characters. "
                "Can not start or end with whitespace.",
                exc.cause.format_message())