Пример #1
0
class TestIntegerOptionWithDefault(TestIntegerOptionNoDefault):
    """Tests IntegerOption with a default value."""

    def setUp(self):
        self.option = IntegerOption(1234)

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

    def test_schema(self):
        """Tests IntegerOption schema method."""
        self.assertRaises(ValidationError, validate, 1.0, self.option.schema())
        self.assertIsNone(validate(5, self.option.schema()))
        self.assertDictEqual(self.option.schema(), {'default': 1234, 'type': 'integer'})
Пример #2
0
class TestIntegerOptionWithDefault(TestIntegerOptionNoDefault):
    """Tests IntegerOption with a default value."""
    def setUp(self):
        self.option = IntegerOption(1234)

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

    def test_schema(self):
        """Tests IntegerOption schema method."""
        self.assertRaises(ValidationError, validate, 1.0, self.option.schema())
        self.assertIsNone(validate(5, self.option.schema()))
        self.assertDictEqual(self.option.schema(), {
            'default': 1234,
            'type': 'integer'
        })
Пример #3
0
class TestIntegerOptionNoDefault(unittest.TestCase, OptionTest):
    """Tests IntegerOption without a default value."""

    valid_success = range(-1000, 1000)

    encode_success = zip(valid_success, map(str, valid_success))

    decode_success = zip(map(str, valid_success), valid_success)
    decode_failure = [
        'hello',
        '1world',
        'test2',
    ]

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

    def test_schema(self):
        """Tests IntegerOption schema method."""
        self.assertRaises(ValidationError, validate, 1.0, self.option.schema())
        self.assertIsNone(validate(5, self.option.schema()))
        self.assertDictEqual(self.option.schema(), {'type': 'integer'})
Пример #4
0
class TestIntegerOptionNoDefault(unittest.TestCase, OptionTest):
    """Tests IntegerOption without a default value."""

    valid_success = range(-1000, 1000)

    encode_success = zip(valid_success, map(str, valid_success))

    decode_success = zip(map(str, valid_success), valid_success)
    decode_failure = [
        'hello',
        '1world',
        'test2',
    ]

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

    def test_schema(self):
        """Tests IntegerOption schema method."""
        self.assertRaises(ValidationError, validate, 1.0, self.option.schema())
        self.assertIsNone(validate(5, self.option.schema()))
        self.assertDictEqual(self.option.schema(), {'type': 'integer'})
Пример #5
0
 def setUp(self):
     self.option = IntegerOption(1234)
Пример #6
0
 def setUp(self):
     self.option = IntegerOption(1234)