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)
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)
def raises_expect_grid(data, expected): with assert_raises(ValidationError) as e: parse_grid(data, "#") eq_(e.exception.message, expected)
def raises_expect_grid(data, expected): try: parse_grid(data, "#") assert False except ValidationError as e: self.assertEqual(e.message, expected)