Show More
@@ -19,7 +19,7 b' from IPython.utils.py3compat import cast_unicode, unicode_type' | |||
|
19 | 19 | # Change this when incrementing the nbformat version |
|
20 | 20 | nbformat = 4 |
|
21 | 21 | nbformat_minor = 0 |
|
22 |
nbformat_schema = ' |
|
|
22 | nbformat_schema = 'nbformat.v4.schema.json' | |
|
23 | 23 | |
|
24 | 24 | class NotebookNode(Struct): |
|
25 | 25 | pass |
@@ -141,8 +141,7 b'' | |||
|
141 | 141 | "level": { |
|
142 | 142 | "description": "Level of heading cells.", |
|
143 | 143 | "type": "integer", |
|
144 |
"minimum": 1 |
|
|
145 | "maximum": 6 | |
|
144 | "minimum": 1 | |
|
146 | 145 | } |
|
147 | 146 | } |
|
148 | 147 | }, |
@@ -8,119 +8,123 b' import os' | |||
|
8 | 8 | |
|
9 | 9 | import nose.tools as nt |
|
10 | 10 | |
|
11 |
from ..validator import |
|
|
11 | from IPython.nbformat.validator import validate, ValidationError | |
|
12 | 12 | from ..nbjson import reads |
|
13 | from ..nbbase import nbformat | |
|
13 | 14 | from ..compose import ( |
|
14 | 15 | new_code_cell, new_heading_cell, new_markdown_cell, new_notebook, |
|
15 | 16 | new_output, new_raw_cell, |
|
16 | 17 | ) |
|
17 | 18 | |
|
19 | def validate4(obj, ref=None): | |
|
20 | return validate(obj, ref, version=nbformat) | |
|
21 | ||
|
18 | 22 | def test_valid_code_cell(): |
|
19 | 23 | cell = new_code_cell() |
|
20 | validate(cell, 'code_cell') | |
|
24 | validate4(cell, 'code_cell') | |
|
21 | 25 | |
|
22 | 26 | def test_invalid_code_cell(): |
|
23 | 27 | cell = new_code_cell() |
|
24 | 28 | |
|
25 | 29 | cell['source'] = 5 |
|
26 | 30 | with nt.assert_raises(ValidationError): |
|
27 | validate(cell, 'code_cell') | |
|
31 | validate4(cell, 'code_cell') | |
|
28 | 32 | |
|
29 | 33 | cell = new_code_cell() |
|
30 | 34 | del cell['metadata'] |
|
31 | 35 | |
|
32 | 36 | with nt.assert_raises(ValidationError): |
|
33 | validate(cell, 'code_cell') | |
|
37 | validate4(cell, 'code_cell') | |
|
34 | 38 | |
|
35 | 39 | cell = new_code_cell() |
|
36 | 40 | del cell['source'] |
|
37 | 41 | |
|
38 | 42 | with nt.assert_raises(ValidationError): |
|
39 | validate(cell, 'code_cell') | |
|
43 | validate4(cell, 'code_cell') | |
|
40 | 44 | |
|
41 | 45 | cell = new_code_cell() |
|
42 | 46 | del cell['cell_type'] |
|
43 | 47 | |
|
44 | 48 | with nt.assert_raises(ValidationError): |
|
45 | validate(cell, 'code_cell') | |
|
49 | validate4(cell, 'code_cell') | |
|
46 | 50 | |
|
47 | 51 | def test_invalid_markdown_cell(): |
|
48 | 52 | cell = new_markdown_cell() |
|
49 | 53 | |
|
50 | 54 | cell['source'] = 5 |
|
51 | 55 | with nt.assert_raises(ValidationError): |
|
52 | validate(cell, 'markdown_cell') | |
|
56 | validate4(cell, 'markdown_cell') | |
|
53 | 57 | |
|
54 | 58 | cell = new_markdown_cell() |
|
55 | 59 | del cell['metadata'] |
|
56 | 60 | |
|
57 | 61 | with nt.assert_raises(ValidationError): |
|
58 | validate(cell, 'markdown_cell') | |
|
62 | validate4(cell, 'markdown_cell') | |
|
59 | 63 | |
|
60 | 64 | cell = new_markdown_cell() |
|
61 | 65 | del cell['source'] |
|
62 | 66 | |
|
63 | 67 | with nt.assert_raises(ValidationError): |
|
64 | validate(cell, 'markdown_cell') | |
|
68 | validate4(cell, 'markdown_cell') | |
|
65 | 69 | |
|
66 | 70 | cell = new_markdown_cell() |
|
67 | 71 | del cell['cell_type'] |
|
68 | 72 | |
|
69 | 73 | with nt.assert_raises(ValidationError): |
|
70 | validate(cell, 'markdown_cell') | |
|
74 | validate4(cell, 'markdown_cell') | |
|
71 | 75 | |
|
72 | 76 | def test_invalid_heading_cell(): |
|
73 | 77 | cell = new_heading_cell() |
|
74 | 78 | |
|
75 | 79 | cell['source'] = 5 |
|
76 | 80 | with nt.assert_raises(ValidationError): |
|
77 | validate(cell, 'heading_cell') | |
|
81 | validate4(cell, 'heading_cell') | |
|
78 | 82 | |
|
79 | 83 | cell = new_heading_cell() |
|
80 | 84 | del cell['metadata'] |
|
81 | 85 | |
|
82 | 86 | with nt.assert_raises(ValidationError): |
|
83 | validate(cell, 'heading_cell') | |
|
87 | validate4(cell, 'heading_cell') | |
|
84 | 88 | |
|
85 | 89 | cell = new_heading_cell() |
|
86 | 90 | del cell['source'] |
|
87 | 91 | |
|
88 | 92 | with nt.assert_raises(ValidationError): |
|
89 | validate(cell, 'heading_cell') | |
|
93 | validate4(cell, 'heading_cell') | |
|
90 | 94 | |
|
91 | 95 | cell = new_heading_cell() |
|
92 | 96 | del cell['cell_type'] |
|
93 | 97 | |
|
94 | 98 | with nt.assert_raises(ValidationError): |
|
95 | validate(cell, 'heading_cell') | |
|
99 | validate4(cell, 'heading_cell') | |
|
96 | 100 | |
|
97 | 101 | def test_invalid_raw_cell(): |
|
98 | 102 | cell = new_raw_cell() |
|
99 | 103 | |
|
100 | 104 | cell['source'] = 5 |
|
101 | 105 | with nt.assert_raises(ValidationError): |
|
102 | validate(cell, 'raw_cell') | |
|
106 | validate4(cell, 'raw_cell') | |
|
103 | 107 | |
|
104 | 108 | cell = new_raw_cell() |
|
105 | 109 | del cell['metadata'] |
|
106 | 110 | |
|
107 | 111 | with nt.assert_raises(ValidationError): |
|
108 | validate(cell, 'raw_cell') | |
|
112 | validate4(cell, 'raw_cell') | |
|
109 | 113 | |
|
110 | 114 | cell = new_raw_cell() |
|
111 | 115 | del cell['source'] |
|
112 | 116 | |
|
113 | 117 | with nt.assert_raises(ValidationError): |
|
114 | validate(cell, 'raw_cell') | |
|
118 | validate4(cell, 'raw_cell') | |
|
115 | 119 | |
|
116 | 120 | cell = new_raw_cell() |
|
117 | 121 | del cell['cell_type'] |
|
118 | 122 | |
|
119 | 123 | with nt.assert_raises(ValidationError): |
|
120 | validate(cell, 'raw_cell') | |
|
124 | validate4(cell, 'raw_cell') | |
|
121 | 125 | |
|
122 | 126 | def test_sample_notebook(): |
|
123 | 127 | here = os.path.dirname(__file__) |
|
124 | 128 | with io.open(os.path.join(here, "v4-test.ipynb"), encoding='utf-8') as f: |
|
125 | 129 | nb = reads(f.read()) |
|
126 | validate(nb) | |
|
130 | validate4(nb) |
@@ -199,6 +199,7 b' def find_package_data():' | |||
|
199 | 199 | 'IPython.nbformat' : [ |
|
200 | 200 | 'tests/*.ipynb', |
|
201 | 201 | 'v3/nbformat.v3.schema.json', |
|
202 | 'v4/nbformat.v4.schema.json', | |
|
202 | 203 | ] |
|
203 | 204 | } |
|
204 | 205 |
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now