Beispiel #1
0
class TestBooleanOptionNoDefault(unittest.TestCase, OptionTest):
    """Tests BooleanOption without a default value."""

    valid_success = [
        True,
        False,
    ]
    valid_failure = [
        'True',
        1337,
    ]

    encode_success = [
        (True, 'true'),
        (False, 'false'),
    ]

    decode_success = [
        ('true', True),
        ('false', False),
    ]

    def setUp(self):
        self.option = BooleanOption()

    def test_schema(self):
        """Tests BooleanOption schema method."""
        self.assertRaises(ValidationError, validate, 4, self.option.schema())
        self.assertIsNone(validate(True, self.option.schema()))
        self.assertDictEqual(self.option.schema(), {'type': 'boolean'})
Beispiel #2
0
class TestBooleanOptionNoDefault(unittest.TestCase, OptionTest):
    """Tests BooleanOption without a default value."""

    valid_success = [
        True,
        False,
    ]
    valid_failure = [
        'True',
        1337,
    ]

    encode_success = [
        (True, 'true'),
        (False, 'false'),
    ]

    decode_success = [
        ('true', True),
        ('false', False),
    ]

    def setUp(self):
        self.option = BooleanOption()

    def test_schema(self):
        """Tests BooleanOption schema method."""
        self.assertRaises(ValidationError, validate, 4, self.option.schema())
        self.assertIsNone(validate(True, self.option.schema()))
        self.assertDictEqual(self.option.schema(), {'type': 'boolean'})
Beispiel #3
0
class TestBooleanOptionWithDefault(TestBooleanOptionNoDefault):
    """Test BooleanOption with a default value."""

    def setUp(self):
        self.option = BooleanOption(False)

    def test_default(self):
        """Tests that the default was set correctly."""
        self.assertEqual(self.option.default, False)

    def test_schema(self):
        """Tests BooleanOption schema method."""
        self.assertRaises(ValidationError, validate, 4, self.option.schema())
        self.assertIsNone(validate(True, self.option.schema()))
        self.assertDictEqual(self.option.schema(), {'default': False, 'type': 'boolean'})
Beispiel #4
0
class TestBooleanOptionWithDefault(TestBooleanOptionNoDefault):
    """Test BooleanOption with a default value."""
    def setUp(self):
        self.option = BooleanOption(False)

    def test_default(self):
        """Tests that the default was set correctly."""
        self.assertEqual(self.option.default, False)

    def test_schema(self):
        """Tests BooleanOption schema method."""
        self.assertRaises(ValidationError, validate, 4, self.option.schema())
        self.assertIsNone(validate(True, self.option.schema()))
        self.assertDictEqual(self.option.schema(), {
            'default': False,
            'type': 'boolean'
        })
Beispiel #5
0
 def setUp(self):
     self.option = BooleanOption(False)
Beispiel #6
0
 def setUp(self):
     self.option = BooleanOption(False)