Skip to content

Commit 3e2a7d1

Browse files
committed
[test/versionConv] Add load json file
1 parent 2a696c6 commit 3e2a7d1

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"Document": {
3+
"version": "v1.13",
4+
"date": "2018-07-07",
5+
"author": "author",
6+
"sections": [
7+
{
8+
"name": "sec_one",
9+
"type" : "mainsec",
10+
"properties": [
11+
{
12+
"name": "prop_one",
13+
"values": [
14+
{
15+
"value": "['one', 'two']",
16+
"dtype": "string"
17+
},
18+
{
19+
"value": "1",
20+
"dtype": "int"
21+
}
22+
]
23+
}
24+
],
25+
"sections": [
26+
{
27+
"name": "subsec_one",
28+
"sections": [],
29+
"type": "subsec"
30+
}
31+
]
32+
}
33+
]
34+
},
35+
"odml-version": "1"
36+
}

test/test_version_converter.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,3 +544,20 @@ def test_convert_yaml_file(self):
544544
prop = sec.find("property")
545545
self.assertIsNotNone(prop.find("name"))
546546
self.assertIsNotNone(prop.find("value"))
547+
548+
def test_convert_json_file(self):
549+
# Test minimal reading from a json file.
550+
basefile = os.path.join(self.basepath, "version_conversion.json")
551+
552+
root = self.VC(basefile)._parse_json().getroot()
553+
self.assertIsNotNone(root.find("section"))
554+
555+
sec = root.find("section")
556+
self.assertIsNotNone(sec.find("name"))
557+
self.assertIsNotNone(sec.find("type"))
558+
self.assertIsNotNone(sec.find("section"))
559+
self.assertIsNotNone(sec.find("property"))
560+
561+
prop = sec.find("property")
562+
self.assertIsNotNone(prop.find("name"))
563+
self.assertIsNotNone(prop.find("value"))

0 commit comments

Comments
 (0)