Skip to content

Commit 1e729fd

Browse files
committed
added end to end test for schema_inferer script
1 parent 900d27b commit 1e729fd

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ htmlcov
3434
.mr.developer.cfg
3535
.project
3636
.pydevproject
37+
.idea
3738

3839
# Complexity
3940
output/*.html

bin/schema_inferer

+2-5
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@
33
"""Generates a JSON schema based on samples
44
"""
55

6-
from __future__ import absolute_import, division, print_function
6+
from __future__ import absolute_import, print_function
77

8-
import sys
9-
import os
10-
sys.path.append(os.path.dirname(os.path.dirname(__file__)))
11-
from skinfer import schema_inferer
128
import json
9+
from skinfer import schema_inferer
1310

1411

1512
def get_samples(samples, jsonlines=False):

tests/test_end_to_end.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import json
2+
import unittest
3+
import subprocess
4+
import tempfile
5+
6+
7+
class BinSchemaInferer(unittest.TestCase):
8+
def test_end_to_end_simple_run(self):
9+
# given:
10+
_, filename = tempfile.mkstemp()
11+
with open(filename, 'w') as f:
12+
f.write('{"one": "two"}')
13+
14+
expected = {
15+
"$schema": "http://json-schema.org/draft-04/schema",
16+
"required": [
17+
"one"
18+
],
19+
"type": "object",
20+
"properties": {
21+
"one": {
22+
"type": "string"
23+
}
24+
}
25+
}
26+
27+
# when:
28+
output = subprocess.check_output(['schema_inferer', filename])
29+
# then:
30+
self.assertEqual(expected, json.loads(output))

0 commit comments

Comments
 (0)