mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-23 00:29:59 +02:00
add tests
This commit is contained in:
1
tests/fixtures/generic/csv-10k-sales-records-streaming.json
vendored
Normal file
1
tests/fixtures/generic/csv-10k-sales-records-streaming.json
vendored
Normal file
File diff suppressed because one or more lines are too long
1
tests/fixtures/generic/csv-deniro-streaming.json
vendored
Normal file
1
tests/fixtures/generic/csv-deniro-streaming.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
[{"Year":"1968","Score":"86","Title":"Greetings"},{"Year":"1970","Score":"17","Title":"Bloody Mama"},{"Year":"1970","Score":"73","Title":"Hi, Mom!"},{"Year":"1971","Score":"40","Title":"Born to Win"},{"Year":"1973","Score":"98","Title":"Mean Streets"},{"Year":"1973","Score":"88","Title":"Bang the Drum Slowly"},{"Year":"1974","Score":"97","Title":"The Godfather, Part II"},{"Year":"1976","Score":"41","Title":"The Last Tycoon"},{"Year":"1976","Score":"99","Title":"Taxi Driver"},{"Year":"1977","Score":"47","Title":"1900"},{"Year":"1977","Score":"67","Title":"New York, New York"},{"Year":"1978","Score":"93","Title":"The Deer Hunter"},{"Year":"1980","Score":"97","Title":"Raging Bull"},{"Year":"1981","Score":"75","Title":"True Confessions"},{"Year":"1983","Score":"90","Title":"The King of Comedy"},{"Year":"1984","Score":"89","Title":"Once Upon a Time in America"},{"Year":"1984","Score":"60","Title":"Falling in Love"},{"Year":"1985","Score":"98","Title":"Brazil"},{"Year":"1986","Score":"65","Title":"The Mission"},{"Year":"1987","Score":"100","Title":"Dear America: Letters Home From Vietnam"},{"Year":"1987","Score":"80","Title":"The Untouchables"},{"Year":"1987","Score":"78","Title":"Angel Heart"},{"Year":"1988","Score":"96","Title":"Midnight Run"},{"Year":"1989","Score":"64","Title":"Jacknife"},{"Year":"1989","Score":"47","Title":"We're No Angels"},{"Year":"1990","Score":"88","Title":"Awakenings"},{"Year":"1990","Score":"29","Title":"Stanley & Iris"},{"Year":"1990","Score":"96","Title":"Goodfellas"},{"Year":"1991","Score":"76","Title":"Cape Fear"},{"Year":"1991","Score":"69","Title":"Mistress"},{"Year":"1991","Score":"65","Title":"Guilty by Suspicion"},{"Year":"1991","Score":"71","Title":"Backdraft"},{"Year":"1992","Score":"87","Title":"Thunderheart"},{"Year":"1992","Score":"67","Title":"Night and the City"},{"Year":"1993","Score":"75","Title":"This Boy's Life"},{"Year":"1993","Score":"78","Title":"Mad Dog and Glory"},{"Year":"1993","Score":"96","Title":"A Bronx Tale"},{"Year":"1994","Score":"39","Title":"Mary Shelley's Frankenstein"},{"Year":"1995","Score":"80","Title":"Casino"},{"Year":"1995","Score":"86","Title":"Heat"},{"Year":"1996","Score":"74","Title":"Sleepers"},{"Year":"1996","Score":"38","Title":"The Fan"},{"Year":"1996","Score":"80","Title":"Marvin's Room"},{"Year":"1997","Score":"85","Title":"Wag the Dog"},{"Year":"1997","Score":"87","Title":"Jackie Brown"},{"Year":"1997","Score":"72","Title":"Cop Land"},{"Year":"1998","Score":"68","Title":"Ronin"},{"Year":"1998","Score":"38","Title":"Great Expectations"},{"Year":"1999","Score":"69","Title":"Analyze This"},{"Year":"1999","Score":"43","Title":"Flawless"},{"Year":"2000","Score":"43","Title":"The Adventures of Rocky & Bullwinkle"},{"Year":"2000","Score":"84","Title":"Meet the Parents"},{"Year":"2000","Score":"41","Title":"Men of Honor"},{"Year":"2001","Score":"73","Title":"The Score"},{"Year":"2001","Score":"33","Title":"15 Minutes"},{"Year":"2002","Score":"48","Title":"City by the Sea"},{"Year":"2002","Score":"27","Title":"Analyze That"},{"Year":"2003","Score":"4","Title":"Godsend"},{"Year":"2004","Score":"35","Title":"Shark Tale"},{"Year":"2004","Score":"38","Title":"Meet the Fockers"},{"Year":"2005","Score":"4","Title":"The Bridge of San Luis Rey"},{"Year":"2005","Score":"46","Title":"Rent"},{"Year":"2005","Score":"13","Title":"Hide and Seek"},{"Year":"2006","Score":"54","Title":"The Good Shepherd"},{"Year":"2007","Score":"21","Title":"Arthur and the Invisibles"},{"Year":"2007","Score":"76","Title":"Captain Shakespeare"},{"Year":"2008","Score":"19","Title":"Righteous Kill"},{"Year":"2008","Score":"51","Title":"What Just Happened?"},{"Year":"2009","Score":"46","Title":"Everybody's Fine"},{"Year":"2010","Score":"72","Title":"Machete"},{"Year":"2010","Score":"10","Title":"Little Fockers"},{"Year":"2010","Score":"50","Title":"Stone"},{"Year":"2011","Score":"25","Title":"Killer Elite"},{"Year":"2011","Score":"7","Title":"New Year's Eve"},{"Year":"2011","Score":"70","Title":"Limitless"},{"Year":"2012","Score":"92","Title":"Silver Linings Playbook"},{"Year":"2012","Score":"51","Title":"Being Flynn"},{"Year":"2012","Score":"29","Title":"Red Lights"},{"Year":"2013","Score":"46","Title":"Last Vegas"},{"Year":"2013","Score":"7","Title":"The Big Wedding"},{"Year":"2013","Score":"29","Title":"Grudge Match"},{"Year":"2013","Score":"11","Title":"Killing Season"},{"Year":"2014","Score":"9","Title":"The Bag Man"},{"Year":"2015","Score":"60","Title":"Joy"},{"Year":"2015","Score":"26","Title":"Heist"},{"Year":"2015","Score":"61","Title":"The Intern"},{"Year":"2016","Score":"11","Title":"Dirty Grandpa"}]
|
1
tests/fixtures/generic/csv-example-streaming.json
vendored
Normal file
1
tests/fixtures/generic/csv-example-streaming.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
[{"TOK": "JET", "UPDATE": "20031201", "DATE": "20001006", "SHOT": "53521", "TIME": "1.000E+01", "AUXHEAT": "NBIC", "PHASE": "HSELM", "STATE": "TRANS", "PGASA": "2.000E+00", "PGASZ": "1.000E+00", "BGASA": "2", "BGASZ": "1", "BGASA2": "0", "BGASZ2": "0", "PIMPA": "1.658E+01", "PIMPZ": "8.152E+00", "PELLET": "NONE", "RGEO": "2.888E+00", "RMAG": "3.047E+00", "AMIN": "9.807E-01", "SEPLIM": "2.924E-02", "XPLIM": "7.304E-02", "KAPPA": "1.572E+00", "DELTA": "1.781E-01", "INDENT": "0.000E+00", "AREA": "4.572E+00", "VOL": "8.161E+01", "CONFIG": "LSN", "IGRADB": "1", "WALMAT": "IN/C", "DIVMAT": "BE", "LIMMAT": "C/BE", "EVAP": "BE", "BT": "3.598E+00", "IP": "2.000E+06", "VSURF": "1.013E-01", "Q95": "6.001E+00", "BEPMHD": "1.053E+00", "BETMHD": "9.252E-01", "BEPDIA": "1.128E+00", "NEL": "3.106E+19", "DNELDT": "3.106E+19", "ZEFF": "6.612E+00", "PRAD": "4.515E+06", "POHM": "5.122E+04", "ENBI": "1.000E+05", "PINJ": "1.466E+07", "BSOURCE": "771706", "PINJ2": "0.000E+00", "BSOURCE2": "652114", "COCTR": "1.000E+00", "PNBI": "1.420E+07", "ECHFREQ": "-9.999E-09", "ECHMODE": "NONE", "ECHLOC": "NONE", "PECH": "0.000E+00", "ICFREQ": "5.100E+07", "ICSCHEME": "HMIN", "ICANTEN": "MONOPOLE", "PICRH": "4.027E+06", "LHFREQ": "3.700E+09", "LHNPAR": "1.840E+00", "PLH": "2.000E+06", "IBWFREQ": "-9.999E-09", "PIBW": "0.000E+00", "TE0": "9.295E+03", "TI0": "1.373E+04", "WFANI": "6.913E-01", "WFICRH": "7.319E+05", "MEFF": "2.000E+00", "ISEQ": "NONE", "WTH": "3.715E+06", "WTOT": "5.381E+06", "DWTOT": "1.282E+06", "PL": "1.297E+07", "PLTH": "1.210E+07", "TAUTOT": "4.445E-01", "TAUTH": "2.194E-01"}]
|
1
tests/fixtures/generic/csv-flyrna-streaming.json
vendored
Normal file
1
tests/fixtures/generic/csv-flyrna-streaming.json
vendored
Normal file
File diff suppressed because one or more lines are too long
1
tests/fixtures/generic/csv-flyrna2-streaming.json
vendored
Normal file
1
tests/fixtures/generic/csv-flyrna2-streaming.json
vendored
Normal file
File diff suppressed because one or more lines are too long
1
tests/fixtures/generic/csv-homes-pipe-streaming.json
vendored
Normal file
1
tests/fixtures/generic/csv-homes-pipe-streaming.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
[{"Sell":"142","List":"160","Living":"28","Rooms":"10","Beds":"5","Baths":"3","Age":"60","Acres":"0.28","Taxes":"3167"},{"Sell":"175","List":"180","Living":"18","Rooms":"8","Beds":"4","Baths":"1","Age":"12","Acres":"0.43","Taxes":"4033"}]
|
1
tests/fixtures/generic/csv-homes-streaming.json
vendored
Normal file
1
tests/fixtures/generic/csv-homes-streaming.json
vendored
Normal file
File diff suppressed because one or more lines are too long
1
tests/fixtures/generic/csv-insurance-streaming.json
vendored
Normal file
1
tests/fixtures/generic/csv-insurance-streaming.json
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -41,6 +41,9 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-insurance.csv'), 'r', encoding='utf-8') as f:
|
||||
self.generic_csv_insurance = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-10k-sales-records.csv'), 'r', encoding='utf-8') as f:
|
||||
self.generic_csv_10k_sales_records = f.read()
|
||||
|
||||
# output
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-biostats-streaming.json'), 'r', encoding='utf-8') as f:
|
||||
self.generic_csv_biostats_streaming_json = json.loads(f.read())
|
||||
@ -48,26 +51,29 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-cities-streaming.json'), 'r', encoding='utf-8') as f:
|
||||
self.generic_csv_cities_streaming_json = json.loads(f.read())
|
||||
|
||||
# with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-deniro-streaming.json'), 'r', encoding='utf-8') as f:
|
||||
# self.generic_csv_deniro_json = json.loads(f.read())
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-deniro-streaming.json'), 'r', encoding='utf-8') as f:
|
||||
self.generic_csv_deniro_streaming_json = json.loads(f.read())
|
||||
|
||||
# with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-example-streaming.json'), 'r', encoding='utf-8') as f:
|
||||
# self.generic_csv_example_json = json.loads(f.read())
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-example-streaming.json'), 'r', encoding='utf-8') as f:
|
||||
self.generic_csv_example_streaming_json = json.loads(f.read())
|
||||
|
||||
# with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-flyrna-streaming.json'), 'r', encoding='utf-8') as f:
|
||||
# self.generic_csv_flyrna_json = json.loads(f.read())
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-flyrna-streaming.json'), 'r', encoding='utf-8') as f:
|
||||
self.generic_csv_flyrna_streaming_json = json.loads(f.read())
|
||||
|
||||
# with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-flyrna2-streaming.json'), 'r', encoding='utf-8') as f:
|
||||
# self.generic_csv_flyrna2_json = json.loads(f.read())
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-flyrna2-streaming.json'), 'r', encoding='utf-8') as f:
|
||||
self.generic_csv_flyrna2_streaming_json = json.loads(f.read())
|
||||
|
||||
# with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-homes-pipe-streaming.json'), 'r', encoding='utf-8') as f:
|
||||
# self.generic_csv_homes_pipe_json = json.loads(f.read())
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-homes-pipe-streaming.json'), 'r', encoding='utf-8') as f:
|
||||
self.generic_csv_homes_pipe_streaming_json = json.loads(f.read())
|
||||
|
||||
# with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-homes-streaming.json'), 'r', encoding='utf-8') as f:
|
||||
# self.generic_csv_homes_json = json.loads(f.read())
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-homes-streaming.json'), 'r', encoding='utf-8') as f:
|
||||
self.generic_csv_homes_streaming_json = json.loads(f.read())
|
||||
|
||||
# with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-insurance-streaming.json'), 'r', encoding='utf-8') as f:
|
||||
# self.generic_csv_insurance_json = json.loads(f.read())
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-insurance-streaming.json'), 'r', encoding='utf-8') as f:
|
||||
self.generic_csv_insurance_streaming_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-10k-sales-records-streaming.json'), 'r', encoding='utf-8') as f:
|
||||
self.generic_csv_10k_sales_records_streaming_json = json.loads(f.read())
|
||||
|
||||
def test_csv_s_nodata(self):
|
||||
"""
|
||||
@ -82,12 +88,6 @@ class MyTests(unittest.TestCase):
|
||||
# with self.assertRaises(ParseError):
|
||||
# list(g)
|
||||
|
||||
# def test_vmstat_centos_7_7(self):
|
||||
# """
|
||||
# Test 'vmstat' on Centos 7.7
|
||||
# """
|
||||
# self.assertEqual(list(jc.parsers.vmstat_s.parse(self.centos_7_7_vmstat.splitlines(), quiet=True)), self.centos_7_7_vmstat_streaming_json)
|
||||
|
||||
def test_csv_s_biostats(self):
|
||||
"""
|
||||
Test 'biostats.csv' file
|
||||
@ -100,47 +100,53 @@ class MyTests(unittest.TestCase):
|
||||
"""
|
||||
self.assertEqual(list(jc.parsers.csv_s.parse(self.generic_csv_cities.splitlines(), quiet=True)), self.generic_csv_cities_streaming_json)
|
||||
|
||||
# def test_csv_deniro(self):
|
||||
# """
|
||||
# Test 'deniro.csv' file
|
||||
# """
|
||||
# self.assertEqual(jc.parsers.csv.parse(self.generic_csv_deniro, quiet=True), self.generic_csv_deniro_json)
|
||||
def test_csv_s_deniro(self):
|
||||
"""
|
||||
Test 'deniro.csv' file
|
||||
"""
|
||||
self.assertEqual(list(jc.parsers.csv_s.parse(self.generic_csv_deniro.splitlines(), quiet=True)), self.generic_csv_deniro_streaming_json)
|
||||
|
||||
# def test_csv_example(self):
|
||||
# """
|
||||
# Test 'example.csv' file
|
||||
# """
|
||||
# self.assertEqual(jc.parsers.csv.parse(self.generic_csv_example, quiet=True), self.generic_csv_example_json)
|
||||
def test_csv_s_example(self):
|
||||
"""
|
||||
Test 'example.csv' file
|
||||
"""
|
||||
self.assertEqual(list(jc.parsers.csv_s.parse(self.generic_csv_example.splitlines(), quiet=True)), self.generic_csv_example_streaming_json)
|
||||
|
||||
# def test_csv_flyrna(self):
|
||||
# """
|
||||
# Test 'flyrna.tsv' file
|
||||
# """
|
||||
# self.assertEqual(jc.parsers.csv.parse(self.generic_csv_flyrna, quiet=True), self.generic_csv_flyrna_json)
|
||||
def test_csv_s_flyrna(self):
|
||||
"""
|
||||
Test 'flyrna.tsv' file
|
||||
"""
|
||||
self.assertEqual(list(jc.parsers.csv_s.parse(self.generic_csv_flyrna.splitlines(), quiet=True)), self.generic_csv_flyrna_streaming_json)
|
||||
|
||||
# def test_csv_flyrna2(self):
|
||||
# """
|
||||
# Test 'flyrna2.tsv' file
|
||||
# """
|
||||
# self.assertEqual(jc.parsers.csv.parse(self.generic_csv_flyrna2, quiet=True), self.generic_csv_flyrna2_json)
|
||||
def test_csv_s_flyrna2(self):
|
||||
"""
|
||||
Test 'flyrna2.tsv' file
|
||||
"""
|
||||
self.assertEqual(list(jc.parsers.csv_s.parse(self.generic_csv_flyrna2.splitlines(), quiet=True)), self.generic_csv_flyrna2_streaming_json)
|
||||
|
||||
# def test_csv_homes_pipe(self):
|
||||
# """
|
||||
# Test 'homes-pipe.csv' file
|
||||
# """
|
||||
# self.assertEqual(jc.parsers.csv.parse(self.generic_csv_homes_pipe, quiet=True), self.generic_csv_homes_pipe_json)
|
||||
def test_csv_s_homes_pipe(self):
|
||||
"""
|
||||
Test 'homes-pipe.csv' file
|
||||
"""
|
||||
self.assertEqual(list(jc.parsers.csv_s.parse(self.generic_csv_homes_pipe.splitlines(), quiet=True)), self.generic_csv_homes_pipe_streaming_json)
|
||||
|
||||
# def test_csv_homes(self):
|
||||
# """
|
||||
# Test 'homes.csv' file
|
||||
# """
|
||||
# self.assertEqual(jc.parsers.csv.parse(self.generic_csv_homes, quiet=True), self.generic_csv_homes_json)
|
||||
def test_csv_s_homes(self):
|
||||
"""
|
||||
Test 'homes.csv' file
|
||||
"""
|
||||
self.assertEqual(list(jc.parsers.csv_s.parse(self.generic_csv_homes.splitlines(), quiet=True)), self.generic_csv_homes_streaming_json)
|
||||
|
||||
# def test_csv_insurance(self):
|
||||
# """
|
||||
# Test 'insurance.csv' file
|
||||
# """
|
||||
# self.assertEqual(jc.parsers.csv.parse(self.generic_csv_insurance, quiet=True), self.generic_csv_insurance_json)
|
||||
def test_csv_s_insurance(self):
|
||||
"""
|
||||
Test 'insurance.csv' file
|
||||
"""
|
||||
self.assertEqual(list(jc.parsers.csv_s.parse(self.generic_csv_insurance.splitlines(), quiet=True)), self.generic_csv_insurance_streaming_json)
|
||||
|
||||
def test_csv_s_10k_records(self):
|
||||
"""
|
||||
Test '10k-sales-records.csv' file
|
||||
"""
|
||||
self.assertEqual(list(jc.parsers.csv_s.parse(self.generic_csv_10k_sales_records.splitlines(), quiet=True)), self.generic_csv_10k_sales_records_streaming_json)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Reference in New Issue
Block a user