File tree 3 files changed +33
-5
lines changed
3 files changed +33
-5
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ htmlcov
34
34
.mr.developer.cfg
35
35
.project
36
36
.pydevproject
37
+ .idea
37
38
38
39
# Complexity
39
40
output /* .html
Original file line number Diff line number Diff line change 3
3
"""Generates a JSON schema based on samples
4
4
"""
5
5
6
- from __future__ import absolute_import , division , print_function
6
+ from __future__ import absolute_import , print_function
7
7
8
- import sys
9
- import os
10
- sys .path .append (os .path .dirname (os .path .dirname (__file__ )))
11
- from skinfer import schema_inferer
12
8
import json
9
+ from skinfer import schema_inferer
13
10
14
11
15
12
def get_samples (samples , jsonlines = False ):
Original file line number Diff line number Diff line change
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 ))
You can’t perform that action at this time.
0 commit comments