コード例 #1
0
ファイル: tests.py プロジェクト: thatmattbone/docrequest
    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")
コード例 #2
0
ファイル: tests.py プロジェクト: thatmattbone/docrequest
    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")
コード例 #3
0
ファイル: tests.py プロジェクト: thatmattbone/docrequest
    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")
コード例 #4
0
ファイル: tests.py プロジェクト: thatmattbone/docrequest
    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")
コード例 #5
0
ファイル: tests.py プロジェクト: thatmattbone/docrequest
    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")
コード例 #6
0
ファイル: tests.py プロジェクト: thatmattbone/docrequest
    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")
コード例 #7
0
ファイル: tests.py プロジェクト: thatmattbone/docrequest
    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")
コード例 #8
0
ファイル: tests.py プロジェクト: thatmattbone/docrequest
    def test_missing_mapping(self):
        lines = [" :param foobar fizzle: my description"]

        for line in lines:
            self.assertRaises(Exception, lambda: schema_node_for_line(line))
コード例 #9
0
ファイル: tests.py プロジェクト: thatmattbone/docrequest
 def test_failure(self):
     line = "invalid"
     self.assertRaises(Exception, lambda: schema_node_for_line(line))