Exemplo n.º 1
0
    def test_table(self):
        def raises_expect_table(data, expected):
            try:
                parse_table(data, "#")
                assert False
            except ValidationError as e:
                self.assertEqual(e.message, expected)

        raises_expect_table({}, "#: property 'type' is required")
        raises_expect_table({"type": "table"}, "#: property 'rows' is required")
        raises_expect_table({"type": "table", "rows": 123, "headers": [{"type": "text", "text": "t"}]},
                            "#.rows: must be an array")

        raises_expect_table({"type": "table", "rows": [], "headers": [{"type": "text", "text": "t"}]},
                            "#.rows: must not be empty")
        raises_expect_table({"type": "table", "rows": [{"type": "hline"}], "headers": [{"type": "text", "text": "t"}]},
                            "#.rows[0]: must be an array")
        raises_expect_table({"type": "table", "rows": [[{"type": "hline"}]],
                             "headers": [[{"type": "text", "text": " "}]]},
                            "#.headers[0]: must be an object")

        parse_table({"type": "table", "rows": [[{"type": "hline"}]], "headers": [{"type": "text", "text": " "}]}, "")

        d = {'version': 1, 'title': 'title', 'elements': [
            {"type": "table", "rows": [[{"type": "hline"}]], "headers": [{"type": "text", "text": " "}]}
        ]}
        parse_document(d)
Exemplo n.º 2
0
 def raises_expect_table(data, expected):
     with assert_raises(ValidationError) as e:
         parse_table(data, "#")
     eq_(e.exception.message, expected)
Exemplo n.º 3
0
 def raises_expect_table(data, expected):
     try:
         parse_table(data, "#")
         assert False
     except ValidationError as e:
         self.assertEqual(e.message, expected)