예제 #1
0
파일: test_markup.py 프로젝트: clixnerd/cli
def test_grid():
    def raises_expect_grid(data, expected):
        with assert_raises(ValidationError) as e:
            parse_grid(data, "#")
        eq_(e.exception.message, expected)


    raises_expect_grid({}, "#: property 'type' is required")
    raises_expect_grid({"type": "grid"}, "#: property 'rows' is required")
    raises_expect_grid({"type": "grid", "rows": 123}, "#.rows: must be an array")
    raises_expect_grid({"type": "grid", "rows": []}, "#.rows: must not be empty")
    raises_expect_grid({"type": "grid", "rows": [{"type": "hline"}]}, "#.rows[0]: must be an array")

    parse_grid({"type": "grid", "rows": [[{"type": "hline"}]]}, "")

    d = {'version': 1, 'title': 'title', 'elements': [{"type": "grid", "rows": [[{"type": "hline"}], [{"type": "hline"}]]}]}
    parse_document(d)
예제 #2
0
    def test_grid(self):
        def raises_expect_grid(data, expected):
            try:
                parse_grid(data, "#")
                assert False
            except ValidationError as e:
                self.assertEqual(e.message, expected)

        raises_expect_grid({}, "#: property 'type' is required")
        raises_expect_grid({"type": "grid"}, "#: property 'rows' is required")
        raises_expect_grid({"type": "grid", "rows": 123}, "#.rows: must be an array")
        raises_expect_grid({"type": "grid", "rows": []}, "#.rows: must not be empty")
        raises_expect_grid({"type": "grid", "rows": [{"type": "hline"}]}, "#.rows[0]: must be an array")

        parse_grid({"type": "grid", "rows": [[{"type": "hline"}]]}, "")

        d = {'version': 1, 'title': 'title',
             'elements': [{"type": "grid", "rows": [[{"type": "hline"}], [{"type": "hline"}]]}]}
        parse_document(d)
예제 #3
0
파일: test_markup.py 프로젝트: clixnerd/cli
 def raises_expect_grid(data, expected):
     with assert_raises(ValidationError) as e:
         parse_grid(data, "#")
     eq_(e.exception.message, expected)
예제 #4
0
 def raises_expect_grid(data, expected):
     try:
         parse_grid(data, "#")
         assert False
     except ValidationError as e:
         self.assertEqual(e.message, expected)