Skip to content

Commit 46c78d0

Browse files
committed
[#77] Add a test of titles and rollUp
1 parent ad7669c commit 46c78d0

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

flattentool/tests/test_schema_parser.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ def test_rollup():
341341
assert set(parser.sub_sheets) == set(['testA'])
342342
assert set(parser.sub_sheets['testA']) == set(['ocid', 'testB', 'testC'])
343343

344+
344345
def test_bad_rollup(recwarn):
345346
'''
346347
When rollUp is specified, but the field is missing in the schema, we expect
@@ -486,6 +487,35 @@ def test_use_titles(recwarn):
486487
assert 'does not have a title' in text_type(w.message)
487488

488489

490+
def test_titles_rollup():
491+
parser = SchemaParser(root_schema_dict={
492+
'properties': {
493+
'testA': {
494+
'type': 'array',
495+
'title': 'ATitle',
496+
'rollUp': [ 'testB' ],
497+
'items': {
498+
'type': 'object',
499+
'properties': {
500+
'testB': {
501+
'type': 'string',
502+
'title': 'BTitle',
503+
},
504+
'testC': {
505+
'type': 'string',
506+
'title': 'CTitle',
507+
}
508+
}
509+
}
510+
},
511+
}
512+
}, rollup=True, use_titles=True)
513+
parser.parse()
514+
assert set(parser.main_sheet) == set(['ATitle:BTitle'])
515+
assert set(parser.sub_sheets) == set(['testA'])
516+
assert set(parser.sub_sheets['testA']) == set(['ocid', 'BTitle', 'CTitle'])
517+
518+
489519
def test_schema_from_uri(httpserver):
490520
httpserver.serve_content('{"a":{"$ref":"#/b"}, "b":"c"}', 404)
491521
parser = SchemaParser(schema_filename=httpserver.url)

0 commit comments

Comments
 (0)