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'})
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' })
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'})
def setUp(self): self.option = IntegerOption(1234)