Esempio n. 1
0
    def test_float(self):
        lines = [" :param float myfloat: my description"]

        for line in lines:
            schema_node = schema_node_for_line(line)

            self.assertIsInstance(schema_node, colander.SchemaNode)
            self.assertIsInstance(schema_node.typ, colander.Float)
            self.assertEqual(schema_node.name, "myfloat")
Esempio n. 2
0
    def test_str(self):
        lines = [" :param str value2: my description"]

        for line in lines:
            schema_node = schema_node_for_line(line)

            self.assertIsInstance(schema_node, colander.SchemaNode)
            self.assertIsInstance(schema_node.typ, colander.Str)
            self.assertEqual(schema_node.name, "value2")
Esempio n. 3
0
    def test_int(self):
        lines = [" :param int value1: my description"]

        for line in lines:
            schema_node = schema_node_for_line(line)

            self.assertIsInstance(schema_node, colander.SchemaNode)
            self.assertIsInstance(schema_node.typ, colander.Int)
            self.assertEqual(schema_node.name, "value1")
Esempio n. 4
0
    def test_list_int(self):
        lines = [":param [int] myintlist: my integer list"]

        for line in lines:
            schema_node = schema_node_for_line(line)

            self.assertIsInstance(schema_node, colander.SchemaNode)
            self.assertIsInstance(schema_node.typ, colander.Sequence)
            self.assertIsInstance(schema_node.children[0].typ, colander.Int)
            self.assertEqual(schema_node.name, "myintlist")
Esempio n. 5
0
    def test_choices_float(self):
        lines = [":param float<42.42, 39.39, 52.52> myfloatchoices: my float choices"]

        for line in lines:
            schema_node = schema_node_for_line(line)

            self.assertIsInstance(schema_node, colander.SchemaNode)
            self.assertIsInstance(schema_node.typ, colander.Float)
            self.assertIsInstance(schema_node.validator, colander.OneOf)
            self.assertEqual(schema_node.validator.choices, [42.42, 39.39, 52.52])
            self.assertEqual(schema_node.name, "myfloatchoices")
Esempio n. 6
0
    def test_choices_str(self):
        lines = [":param str<foo, bar, baz> mystrchoices: my string choices"]

        for line in lines:
            schema_node = schema_node_for_line(line)

            self.assertIsInstance(schema_node, colander.SchemaNode)
            self.assertIsInstance(schema_node.typ, colander.Str)
            self.assertIsInstance(schema_node.validator, colander.OneOf)
            self.assertEqual(schema_node.validator.choices, ['foo', 'bar', 'baz'])
            self.assertEqual(schema_node.name, "mystrchoices")
Esempio n. 7
0
    def test_choices_int(self):
        lines = [":param int<1,2,3> myintchoices: my integer choices"]

        for line in lines:
            schema_node = schema_node_for_line(line)

            self.assertIsInstance(schema_node, colander.SchemaNode)
            self.assertIsInstance(schema_node.typ, colander.Int)
            self.assertIsInstance(schema_node.validator, colander.OneOf)
            self.assertEqual(schema_node.validator.choices, [1, 2, 3])
            self.assertEqual(schema_node.name, "myintchoices")
Esempio n. 8
0
    def test_missing_mapping(self):
        lines = [" :param foobar fizzle: my description"]

        for line in lines:
            self.assertRaises(Exception, lambda: schema_node_for_line(line))
Esempio n. 9
0
 def test_failure(self):
     line = "invalid"
     self.assertRaises(Exception, lambda: schema_node_for_line(line))