Skip to content

Commit 651e1df

Browse files
committed
add test
1 parent 45a8fb4 commit 651e1df

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

fixture/files/raw.1.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"a":{"b":1}}, {"a":{"c":2}}]

tests/test_jsoncsv.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,10 @@ def test_jsoncsv_expand(self):
1414
runner = CliRunner()
1515
args = ['-e', 'fixture/files/raw.0.json', 'fixture/files/tmp.expand.0.json']
1616
result = runner.invoke(jsoncsv, args=args)
17-
print(result)
17+
assert result.exit_code == 0
18+
19+
def test_jsoncsv_expand_with_json_array(self):
20+
runner = CliRunner()
21+
args = ['-e', 'fixture/files/raw.1.json', 'fixture/files/tmp.expand.1.json', '-A']
22+
result = runner.invoke(jsoncsv, args=args)
1823
assert result.exit_code == 0

tests/test_jsontool.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,17 @@ def test_convert_restore(self):
120120

121121
fin.close()
122122
fout.close()
123+
124+
def test_convert_expand_json_array(self):
125+
fin = io.StringIO('[{"a":{"b":3}},{"a":{"c":4}}]')
126+
if PY2:
127+
fout = io.BytesIO()
128+
else:
129+
fout = io.StringIO()
130+
131+
convert_json(fin, fout, expand, json_array=True)
132+
133+
self.assertEqual('{"a.b": 3}\n{"a.c": 4}\n', fout.getvalue())
134+
135+
fin.close()
136+
fout.close()

0 commit comments

Comments
 (0)