Skip to content

Commit 5c6fd9d

Browse files
committed
☔ better test coverage
1 parent 4c3ef86 commit 5c6fd9d

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{"a": 1}
2+
{"b": 2}
3+
{"c": 3}

tests/fixtures/uknown.ndjson

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
'a'
2+
{"b": 2}
3+
{"c": 3}

tests/test_ndjsonr.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@ class TestStructure:
1010
def setUp(self):
1111
self.parser = JsonParser("json")
1212

13+
def test_key_value_dict(self):
14+
sheet_name = 'test'
15+
self.content = self.parser.parse_file(
16+
get_file("key_value_dict.ndjson"),
17+
struct=DICT,
18+
sheet_name=sheet_name)
19+
expected = {
20+
sheet_name: [
21+
[u'a', 1],
22+
[u'b', 2],
23+
[u'c', 3]
24+
]
25+
}
26+
self._verify(expected)
27+
1328
def test_dict(self):
1429
sheet_name = 'test'
1530
self.content = self.parser.parse_file(get_file("dict.ndjson"),
@@ -66,12 +81,18 @@ def test_auto_detect_records(self):
6681
self._verify(expected)
6782

6883
@raises(Exception)
69-
def test_unknown(self):
84+
def test_unknown_as_struct(self):
7085
sheet_name = 'test'
7186
self.content = self.parser.parse_file(get_file("records.ndjson"),
7287
struct='unknown',
7388
sheet_name=sheet_name)
7489

90+
@raises(Exception)
91+
def test_unknown_format(self):
92+
sheet_name = 'test'
93+
self.content = self.parser.parse_file(get_file("unknown.ndjson"),
94+
sheet_name=sheet_name)
95+
7596
def _verify(self, expected):
7697
for key in self.content:
7798
self.content[key] = list(self.content[key])

0 commit comments

Comments
 (0)