示例#1
0
 def test_boolean_parser_returns_true(self):
     """
     Tests that the boolean parser returns true for string values that
     say 'true'
     """
     self.assertTrue(FieldValueParsers.boolean_parser('true'))
     self.assertTrue(FieldValueParsers.boolean_parser('TRUE'))
示例#2
0
 def test_boolean_parser_returns_false(self):
     """
     Tests that the boolean parser returns false for string values
     that say 'false'.
     """
     self.assertFalse(FieldValueParsers.boolean_parser('false'))
     self.assertFalse(FieldValueParsers.boolean_parser('FALSE'))
示例#3
0
    def test_boolean_parser_raises_error(self):
        """
        Tests that the boolean parser raises a FieldValueParsingError
        with an INVALID_BOOLEAN_CHOICE message if the given value is
        not 'true' or 'false'
        """
        with self.assertRaises(FieldValueParsingError) as error:
            FieldValueParsers.boolean_parser('blah')

        self.assertEqual(
            str(error.exception),
            FieldValueParsers.INVALID_BOOLEAN_CHOICE,
        )