Skip to content

Commit 7d14a6c

Browse files
committed
tests: Test for use-titles: Use $ref'erring title if available
commit 6219ec7 #368
1 parent 6219ec7 commit 7d14a6c

File tree

8 files changed

+61
-1
lines changed

8 files changed

+61
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$ flatten-tool flatten --root-list-path=weather --main-sheet-name=weather --use-titles --schema=examples/titles-ref/schema.json examples/titles-ref/flatten/data.json -f csv -o examples/titles-ref/flatten/actual
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"weather": [
3+
{
4+
"id": "monday",
5+
"rain": "tons and tons",
6+
"thunder": "none"
7+
},
8+
{
9+
"id": "tuesday",
10+
"rain": "dry as a bone",
11+
"thunder": "loud as fireworks night"
12+
}
13+
]
14+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Identifier,Was it soggy?,Was it noisy?
2+
monday,tons and tons,none
3+
tuesday,dry as a bone,loud as fireworks night

examples/titles-ref/schema.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"definitions": {
4+
"Value": {
5+
"type": "string",
6+
"title": "A lowly string"
7+
}
8+
},
9+
"type": "object",
10+
"properties": {
11+
"id": {
12+
"type": "string",
13+
"title": "Identifier"
14+
},
15+
"rain": {
16+
"$ref": "#/definitions/Value",
17+
"title": "Was it soggy?"
18+
},
19+
"thunder": {
20+
"$ref": "#/definitions/Value",
21+
"title": "Was it noisy?"
22+
}
23+
}
24+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$ flatten-tool unflatten -f csv --root-list-path=weather --convert-titles --schema=examples/titles-ref/schema.json examples/titles-ref/unflatten/data
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Identifier,Was it soggy?,Was it noisy?
2+
1st,tons and tons,none
3+
2nd,dry as a bone,loud as fireworks night
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"weather": [
3+
{
4+
"id": "1st",
5+
"rain": "tons and tons",
6+
"thunder": "none"
7+
},
8+
{
9+
"id": "2nd",
10+
"rain": "dry as a bone",
11+
"thunder": "loud as fireworks night"
12+
}
13+
]
14+
}

flattentool/tests/test_docs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def test_example_in_doc(root, filename):
133133

134134

135135
def test_expected_number_of_examples_in_docs_data():
136-
assert len(examples_in_docs_data) == 57
136+
assert len(examples_in_docs_data) == 59
137137

138138

139139
def _simplify_warnings(lines):

0 commit comments

Comments
 (0)