コード例 #1
0
ファイル: test_string.py プロジェクト: yiqideren/freeseer
class TestStringOptionNoDefault(unittest.TestCase, OptionTest):
    """Tests StringOption without a default value."""

    valid_success = [
        'testing',
        True,
        0,
    ]

    encode_success = [
        ('testing', 'testing'),
        (True, 'True'),
    ]

    decode_success = [
        ('testing', 'testing'),
        ('True', 'True'),
    ]

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

    def test_schema(self):
        """Tests StringOption schema method."""
        self.assertRaises(ValidationError, validate, 1, self.option.schema())
        self.assertIsNone(validate('string_value', self.option.schema()))
        self.assertDictEqual(self.option.schema(), {'type': 'string'})
コード例 #2
0
ファイル: test_string.py プロジェクト: Promm/freeseer
class TestStringOptionWithDefault(TestStringOptionNoDefault):
    """Tests StringOption with a default value."""

    def setUp(self):
        self.option = StringOption("testing")

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

    def test_schema(self):
        """Tests StringOption schema method."""
        self.assertRaises(ValidationError, validate, 1, self.option.schema())
        self.assertIsNone(validate("string_value", self.option.schema()))
        self.assertDictEqual(self.option.schema(), {"default": "testing", "type": "string"})
コード例 #3
0
ファイル: test_string.py プロジェクト: yiqideren/freeseer
class TestStringOptionWithDefault(TestStringOptionNoDefault):
    """Tests StringOption with a default value."""
    def setUp(self):
        self.option = StringOption('testing')

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

    def test_schema(self):
        """Tests StringOption schema method."""
        self.assertRaises(ValidationError, validate, 1, self.option.schema())
        self.assertIsNone(validate('string_value', self.option.schema()))
        self.assertDictEqual(self.option.schema(), {
            'default': 'testing',
            'type': 'string'
        })
コード例 #4
0
ファイル: test_string.py プロジェクト: Promm/freeseer
class TestStringOptionNoDefault(unittest.TestCase, OptionTest):
    """Tests StringOption without a default value."""

    valid_success = ["testing", True, 0]

    encode_success = [("testing", "testing"), (True, "True")]

    decode_success = [("testing", "testing"), ("True", "True")]

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

    def test_schema(self):
        """Tests StringOption schema method."""
        self.assertRaises(ValidationError, validate, 1, self.option.schema())
        self.assertIsNone(validate("string_value", self.option.schema()))
        self.assertDictEqual(self.option.schema(), {"type": "string"})