class TestChoiceOptionWithDefault(TestChoiceOptionNoDefault): """Tests ChoiceOption with a default value.""" def setUp(self): self.option = ChoiceOption([ 'hello', 'world', ], 'hello') def test_default(self): """Tests that the default was set correctly.""" self.assertEqual(self.option.default, 'hello') def test_schema(self): """Tests a ChoiceOption schema method.""" expected = { 'default': 'hello', 'enum': [ 'hello', 'world', ], } self.assertRaises(ValidationError, validate, 'error', self.option.schema()) self.assertIsNone(validate('world', self.option.schema())) self.assertDictEqual(self.option.schema(), expected)
class TestChoiceOptionWithDefault(TestChoiceOptionNoDefault): """Tests ChoiceOption with a default value.""" def setUp(self): self.option = ChoiceOption(["hello", "world"], "hello") def test_default(self): """Tests that the default was set correctly.""" self.assertEqual(self.option.default, "hello") def test_schema(self): """Tests a ChoiceOption schema method.""" expected = {"default": "hello", "enum": ["hello", "world"]} self.assertRaises(ValidationError, validate, "error", self.option.schema()) self.assertIsNone(validate("world", self.option.schema())) self.assertDictEqual(self.option.schema(), expected)
class TestChoiceOptionNoDefault(unittest.TestCase, OptionTest): """Tests ChoiceOption without a default value.""" valid_success = ["hello", "world"] valid_failure = ["hello1", "1hello", "w0rld"] encode_success = zip(valid_success, valid_success) decode_success = zip(valid_success, valid_success) decode_failure = valid_failure def setUp(self): self.option = ChoiceOption(["hello", "world"]) def test_schema(self): """Tests a ChoiceOption schema method.""" expected = {"enum": ["hello", "world"]} self.assertRaises(ValidationError, validate, "error", self.option.schema()) self.assertIsNone(validate("world", self.option.schema())) self.assertDictEqual(self.option.schema(), expected)
class TestChoiceOptionNoDefault(unittest.TestCase, OptionTest): """Tests ChoiceOption without a default value.""" valid_success = [ 'hello', 'world', ] valid_failure = [ 'hello1', '1hello', 'w0rld', ] encode_success = zip(valid_success, valid_success) decode_success = zip(valid_success, valid_success) decode_failure = valid_failure def setUp(self): self.option = ChoiceOption([ 'hello', 'world', ]) def test_schema(self): """Tests a ChoiceOption schema method.""" expected = { 'enum': [ 'hello', 'world', ], } self.assertRaises(ValidationError, validate, 'error', self.option.schema()) self.assertIsNone(validate('world', self.option.schema())) self.assertDictEqual(self.option.schema(), expected)
def setUp(self): self.option = ChoiceOption([ 'hello', 'world', ], 'hello')
def setUp(self): self.option = ChoiceOption(["hello", "world"], "hello")