From acac0399946d9781193e9350dd7109f1dd3999fe Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Mon, 25 Oct 2021 10:06:01 -0700 Subject: [PATCH] working tests --- .../generic/csv-biostats-streaming.json | 1 + .../generic/csv-cities-streaming.json | 1 + tests/test_csv_s.py | 147 ++++++++++++++++++ 3 files changed, 149 insertions(+) create mode 100644 tests/fixtures/generic/csv-biostats-streaming.json create mode 100644 tests/fixtures/generic/csv-cities-streaming.json create mode 100644 tests/test_csv_s.py diff --git a/tests/fixtures/generic/csv-biostats-streaming.json b/tests/fixtures/generic/csv-biostats-streaming.json new file mode 100644 index 00000000..46f65226 --- /dev/null +++ b/tests/fixtures/generic/csv-biostats-streaming.json @@ -0,0 +1 @@ +[{"Name":"Alex","Sex":"M","Age":"41","Height (in)":"74","Weight (lbs)":"170"},{"Name":"Bert","Sex":"M","Age":"42","Height (in)":"68","Weight (lbs)":"166"},{"Name":"Carl","Sex":"M","Age":"32","Height (in)":"70","Weight (lbs)":"155"},{"Name":"Dave","Sex":"M","Age":"39","Height (in)":"72","Weight (lbs)":"167"},{"Name":"Elly","Sex":"F","Age":"30","Height (in)":"66","Weight (lbs)":"124"},{"Name":"Fran","Sex":"F","Age":"33","Height (in)":"66","Weight (lbs)":"115"},{"Name":"Gwen","Sex":"F","Age":"26","Height (in)":"64","Weight (lbs)":"121"},{"Name":"Hank","Sex":"M","Age":"30","Height (in)":"71","Weight (lbs)":"158"},{"Name":"Ivan","Sex":"M","Age":"53","Height (in)":"72","Weight (lbs)":"175"},{"Name":"Jake","Sex":"M","Age":"32","Height (in)":"69","Weight (lbs)":"143"},{"Name":"Kate","Sex":"F","Age":"47","Height (in)":"69","Weight (lbs)":"139"},{"Name":"Luke","Sex":"M","Age":"34","Height (in)":"72","Weight (lbs)":"163"},{"Name":"Myra","Sex":"F","Age":"23","Height (in)":"62","Weight (lbs)":"98"},{"Name":"Neil","Sex":"M","Age":"36","Height (in)":"75","Weight (lbs)":"160"},{"Name":"Omar","Sex":"M","Age":"38","Height (in)":"70","Weight (lbs)":"145"},{"Name":"Page","Sex":"F","Age":"31","Height (in)":"67","Weight (lbs)":"135"},{"Name":"Quin","Sex":"M","Age":"29","Height (in)":"71","Weight (lbs)":"176"},{"Name":"Ruth","Sex":"F","Age":"28","Height (in)":"65","Weight (lbs)":"131"}] diff --git a/tests/fixtures/generic/csv-cities-streaming.json b/tests/fixtures/generic/csv-cities-streaming.json new file mode 100644 index 00000000..327ed2c0 --- /dev/null +++ b/tests/fixtures/generic/csv-cities-streaming.json @@ -0,0 +1 @@ +[{"LatD":"41","LatM":"5","LatS":"59","NS":"N","LonD":"80","LonM":"39","LonS":"0","EW":"W","City":"Youngstown","State":"OH"},{"LatD":"42","LatM":"52","LatS":"48","NS":"N","LonD":"97","LonM":"23","LonS":"23","EW":"W","City":"Yankton","State":"SD"},{"LatD":"46","LatM":"35","LatS":"59","NS":"N","LonD":"120","LonM":"30","LonS":"36","EW":"W","City":"Yakima","State":"WA"},{"LatD":"42","LatM":"16","LatS":"12","NS":"N","LonD":"71","LonM":"48","LonS":"0","EW":"W","City":"Worcester","State":"MA"},{"LatD":"43","LatM":"37","LatS":"48","NS":"N","LonD":"89","LonM":"46","LonS":"11","EW":"W","City":"Wisconsin Dells","State":"WI"},{"LatD":"36","LatM":"5","LatS":"59","NS":"N","LonD":"80","LonM":"15","LonS":"0","EW":"W","City":"Winston-Salem","State":"NC"},{"LatD":"49","LatM":"52","LatS":"48","NS":"N","LonD":"97","LonM":"9","LonS":"0","EW":"W","City":"Winnipeg","State":"MB"},{"LatD":"39","LatM":"11","LatS":"23","NS":"N","LonD":"78","LonM":"9","LonS":"36","EW":"W","City":"Winchester","State":"VA"},{"LatD":"34","LatM":"14","LatS":"24","NS":"N","LonD":"77","LonM":"55","LonS":"11","EW":"W","City":"Wilmington","State":"NC"},{"LatD":"39","LatM":"45","LatS":"0","NS":"N","LonD":"75","LonM":"33","LonS":"0","EW":"W","City":"Wilmington","State":"DE"},{"LatD":"48","LatM":"9","LatS":"0","NS":"N","LonD":"103","LonM":"37","LonS":"12","EW":"W","City":"Williston","State":"ND"},{"LatD":"41","LatM":"15","LatS":"0","NS":"N","LonD":"77","LonM":"0","LonS":"0","EW":"W","City":"Williamsport","State":"PA"},{"LatD":"37","LatM":"40","LatS":"48","NS":"N","LonD":"82","LonM":"16","LonS":"47","EW":"W","City":"Williamson","State":"WV"},{"LatD":"33","LatM":"54","LatS":"0","NS":"N","LonD":"98","LonM":"29","LonS":"23","EW":"W","City":"Wichita Falls","State":"TX"},{"LatD":"37","LatM":"41","LatS":"23","NS":"N","LonD":"97","LonM":"20","LonS":"23","EW":"W","City":"Wichita","State":"KS"},{"LatD":"40","LatM":"4","LatS":"11","NS":"N","LonD":"80","LonM":"43","LonS":"12","EW":"W","City":"Wheeling","State":"WV"},{"LatD":"26","LatM":"43","LatS":"11","NS":"N","LonD":"80","LonM":"3","LonS":"0","EW":"W","City":"West Palm Beach","State":"FL"},{"LatD":"47","LatM":"25","LatS":"11","NS":"N","LonD":"120","LonM":"19","LonS":"11","EW":"W","City":"Wenatchee","State":"WA"},{"LatD":"41","LatM":"25","LatS":"11","NS":"N","LonD":"122","LonM":"23","LonS":"23","EW":"W","City":"Weed","State":"CA"},{"LatD":"31","LatM":"13","LatS":"11","NS":"N","LonD":"82","LonM":"20","LonS":"59","EW":"W","City":"Waycross","State":"GA"},{"LatD":"44","LatM":"57","LatS":"35","NS":"N","LonD":"89","LonM":"38","LonS":"23","EW":"W","City":"Wausau","State":"WI"},{"LatD":"42","LatM":"21","LatS":"36","NS":"N","LonD":"87","LonM":"49","LonS":"48","EW":"W","City":"Waukegan","State":"IL"},{"LatD":"44","LatM":"54","LatS":"0","NS":"N","LonD":"97","LonM":"6","LonS":"36","EW":"W","City":"Watertown","State":"SD"},{"LatD":"43","LatM":"58","LatS":"47","NS":"N","LonD":"75","LonM":"55","LonS":"11","EW":"W","City":"Watertown","State":"NY"},{"LatD":"42","LatM":"30","LatS":"0","NS":"N","LonD":"92","LonM":"20","LonS":"23","EW":"W","City":"Waterloo","State":"IA"},{"LatD":"41","LatM":"32","LatS":"59","NS":"N","LonD":"73","LonM":"3","LonS":"0","EW":"W","City":"Waterbury","State":"CT"},{"LatD":"38","LatM":"53","LatS":"23","NS":"N","LonD":"77","LonM":"1","LonS":"47","EW":"W","City":"Washington","State":"DC"},{"LatD":"41","LatM":"50","LatS":"59","NS":"N","LonD":"79","LonM":"8","LonS":"23","EW":"W","City":"Warren","State":"PA"},{"LatD":"46","LatM":"4","LatS":"11","NS":"N","LonD":"118","LonM":"19","LonS":"48","EW":"W","City":"Walla Walla","State":"WA"},{"LatD":"31","LatM":"32","LatS":"59","NS":"N","LonD":"97","LonM":"8","LonS":"23","EW":"W","City":"Waco","State":"TX"},{"LatD":"38","LatM":"40","LatS":"48","NS":"N","LonD":"87","LonM":"31","LonS":"47","EW":"W","City":"Vincennes","State":"IN"},{"LatD":"28","LatM":"48","LatS":"35","NS":"N","LonD":"97","LonM":"0","LonS":"36","EW":"W","City":"Victoria","State":"TX"},{"LatD":"32","LatM":"20","LatS":"59","NS":"N","LonD":"90","LonM":"52","LonS":"47","EW":"W","City":"Vicksburg","State":"MS"},{"LatD":"49","LatM":"16","LatS":"12","NS":"N","LonD":"123","LonM":"7","LonS":"12","EW":"W","City":"Vancouver","State":"BC"},{"LatD":"46","LatM":"55","LatS":"11","NS":"N","LonD":"98","LonM":"0","LonS":"36","EW":"W","City":"Valley City","State":"ND"},{"LatD":"30","LatM":"49","LatS":"47","NS":"N","LonD":"83","LonM":"16","LonS":"47","EW":"W","City":"Valdosta","State":"GA"},{"LatD":"43","LatM":"6","LatS":"36","NS":"N","LonD":"75","LonM":"13","LonS":"48","EW":"W","City":"Utica","State":"NY"},{"LatD":"39","LatM":"54","LatS":"0","NS":"N","LonD":"79","LonM":"43","LonS":"48","EW":"W","City":"Uniontown","State":"PA"},{"LatD":"32","LatM":"20","LatS":"59","NS":"N","LonD":"95","LonM":"18","LonS":"0","EW":"W","City":"Tyler","State":"TX"},{"LatD":"42","LatM":"33","LatS":"36","NS":"N","LonD":"114","LonM":"28","LonS":"12","EW":"W","City":"Twin Falls","State":"ID"},{"LatD":"33","LatM":"12","LatS":"35","NS":"N","LonD":"87","LonM":"34","LonS":"11","EW":"W","City":"Tuscaloosa","State":"AL"},{"LatD":"34","LatM":"15","LatS":"35","NS":"N","LonD":"88","LonM":"42","LonS":"35","EW":"W","City":"Tupelo","State":"MS"},{"LatD":"36","LatM":"9","LatS":"35","NS":"N","LonD":"95","LonM":"54","LonS":"36","EW":"W","City":"Tulsa","State":"OK"},{"LatD":"32","LatM":"13","LatS":"12","NS":"N","LonD":"110","LonM":"58","LonS":"12","EW":"W","City":"Tucson","State":"AZ"},{"LatD":"37","LatM":"10","LatS":"11","NS":"N","LonD":"104","LonM":"30","LonS":"36","EW":"W","City":"Trinidad","State":"CO"},{"LatD":"40","LatM":"13","LatS":"47","NS":"N","LonD":"74","LonM":"46","LonS":"11","EW":"W","City":"Trenton","State":"NJ"},{"LatD":"44","LatM":"45","LatS":"35","NS":"N","LonD":"85","LonM":"37","LonS":"47","EW":"W","City":"Traverse City","State":"MI"},{"LatD":"43","LatM":"39","LatS":"0","NS":"N","LonD":"79","LonM":"22","LonS":"47","EW":"W","City":"Toronto","State":"ON"},{"LatD":"39","LatM":"2","LatS":"59","NS":"N","LonD":"95","LonM":"40","LonS":"11","EW":"W","City":"Topeka","State":"KS"},{"LatD":"41","LatM":"39","LatS":"0","NS":"N","LonD":"83","LonM":"32","LonS":"24","EW":"W","City":"Toledo","State":"OH"},{"LatD":"33","LatM":"25","LatS":"48","NS":"N","LonD":"94","LonM":"3","LonS":"0","EW":"W","City":"Texarkana","State":"TX"},{"LatD":"39","LatM":"28","LatS":"12","NS":"N","LonD":"87","LonM":"24","LonS":"36","EW":"W","City":"Terre Haute","State":"IN"},{"LatD":"27","LatM":"57","LatS":"0","NS":"N","LonD":"82","LonM":"26","LonS":"59","EW":"W","City":"Tampa","State":"FL"},{"LatD":"30","LatM":"27","LatS":"0","NS":"N","LonD":"84","LonM":"16","LonS":"47","EW":"W","City":"Tallahassee","State":"FL"},{"LatD":"47","LatM":"14","LatS":"24","NS":"N","LonD":"122","LonM":"25","LonS":"48","EW":"W","City":"Tacoma","State":"WA"},{"LatD":"43","LatM":"2","LatS":"59","NS":"N","LonD":"76","LonM":"9","LonS":"0","EW":"W","City":"Syracuse","State":"NY"},{"LatD":"32","LatM":"35","LatS":"59","NS":"N","LonD":"82","LonM":"20","LonS":"23","EW":"W","City":"Swainsboro","State":"GA"},{"LatD":"33","LatM":"55","LatS":"11","NS":"N","LonD":"80","LonM":"20","LonS":"59","EW":"W","City":"Sumter","State":"SC"},{"LatD":"40","LatM":"59","LatS":"24","NS":"N","LonD":"75","LonM":"11","LonS":"24","EW":"W","City":"Stroudsburg","State":"PA"},{"LatD":"37","LatM":"57","LatS":"35","NS":"N","LonD":"121","LonM":"17","LonS":"24","EW":"W","City":"Stockton","State":"CA"},{"LatD":"44","LatM":"31","LatS":"12","NS":"N","LonD":"89","LonM":"34","LonS":"11","EW":"W","City":"Stevens Point","State":"WI"},{"LatD":"40","LatM":"21","LatS":"36","NS":"N","LonD":"80","LonM":"37","LonS":"12","EW":"W","City":"Steubenville","State":"OH"},{"LatD":"40","LatM":"37","LatS":"11","NS":"N","LonD":"103","LonM":"13","LonS":"12","EW":"W","City":"Sterling","State":"CO"},{"LatD":"38","LatM":"9","LatS":"0","NS":"N","LonD":"79","LonM":"4","LonS":"11","EW":"W","City":"Staunton","State":"VA"},{"LatD":"39","LatM":"55","LatS":"11","NS":"N","LonD":"83","LonM":"48","LonS":"35","EW":"W","City":"Springfield","State":"OH"},{"LatD":"37","LatM":"13","LatS":"12","NS":"N","LonD":"93","LonM":"17","LonS":"24","EW":"W","City":"Springfield","State":"MO"},{"LatD":"42","LatM":"5","LatS":"59","NS":"N","LonD":"72","LonM":"35","LonS":"23","EW":"W","City":"Springfield","State":"MA"},{"LatD":"39","LatM":"47","LatS":"59","NS":"N","LonD":"89","LonM":"39","LonS":"0","EW":"W","City":"Springfield","State":"IL"},{"LatD":"47","LatM":"40","LatS":"11","NS":"N","LonD":"117","LonM":"24","LonS":"36","EW":"W","City":"Spokane","State":"WA"},{"LatD":"41","LatM":"40","LatS":"48","NS":"N","LonD":"86","LonM":"15","LonS":"0","EW":"W","City":"South Bend","State":"IN"},{"LatD":"43","LatM":"32","LatS":"24","NS":"N","LonD":"96","LonM":"43","LonS":"48","EW":"W","City":"Sioux Falls","State":"SD"},{"LatD":"42","LatM":"29","LatS":"24","NS":"N","LonD":"96","LonM":"23","LonS":"23","EW":"W","City":"Sioux City","State":"IA"},{"LatD":"32","LatM":"30","LatS":"35","NS":"N","LonD":"93","LonM":"45","LonS":"0","EW":"W","City":"Shreveport","State":"LA"},{"LatD":"33","LatM":"38","LatS":"23","NS":"N","LonD":"96","LonM":"36","LonS":"36","EW":"W","City":"Sherman","State":"TX"},{"LatD":"44","LatM":"47","LatS":"59","NS":"N","LonD":"106","LonM":"57","LonS":"35","EW":"W","City":"Sheridan","State":"WY"},{"LatD":"35","LatM":"13","LatS":"47","NS":"N","LonD":"96","LonM":"40","LonS":"48","EW":"W","City":"Seminole","State":"OK"},{"LatD":"32","LatM":"25","LatS":"11","NS":"N","LonD":"87","LonM":"1","LonS":"11","EW":"W","City":"Selma","State":"AL"},{"LatD":"38","LatM":"42","LatS":"35","NS":"N","LonD":"93","LonM":"13","LonS":"48","EW":"W","City":"Sedalia","State":"MO"},{"LatD":"47","LatM":"35","LatS":"59","NS":"N","LonD":"122","LonM":"19","LonS":"48","EW":"W","City":"Seattle","State":"WA"},{"LatD":"41","LatM":"24","LatS":"35","NS":"N","LonD":"75","LonM":"40","LonS":"11","EW":"W","City":"Scranton","State":"PA"},{"LatD":"41","LatM":"52","LatS":"11","NS":"N","LonD":"103","LonM":"39","LonS":"36","EW":"W","City":"Scottsbluff","State":"NB"},{"LatD":"42","LatM":"49","LatS":"11","NS":"N","LonD":"73","LonM":"56","LonS":"59","EW":"W","City":"Schenectady","State":"NY"},{"LatD":"32","LatM":"4","LatS":"48","NS":"N","LonD":"81","LonM":"5","LonS":"23","EW":"W","City":"Savannah","State":"GA"},{"LatD":"46","LatM":"29","LatS":"24","NS":"N","LonD":"84","LonM":"20","LonS":"59","EW":"W","City":"Sault Sainte Marie","State":"MI"},{"LatD":"27","LatM":"20","LatS":"24","NS":"N","LonD":"82","LonM":"31","LonS":"47","EW":"W","City":"Sarasota","State":"FL"},{"LatD":"38","LatM":"26","LatS":"23","NS":"N","LonD":"122","LonM":"43","LonS":"12","EW":"W","City":"Santa Rosa","State":"CA"},{"LatD":"35","LatM":"40","LatS":"48","NS":"N","LonD":"105","LonM":"56","LonS":"59","EW":"W","City":"Santa Fe","State":"NM"},{"LatD":"34","LatM":"25","LatS":"11","NS":"N","LonD":"119","LonM":"41","LonS":"59","EW":"W","City":"Santa Barbara","State":"CA"},{"LatD":"33","LatM":"45","LatS":"35","NS":"N","LonD":"117","LonM":"52","LonS":"12","EW":"W","City":"Santa Ana","State":"CA"},{"LatD":"37","LatM":"20","LatS":"24","NS":"N","LonD":"121","LonM":"52","LonS":"47","EW":"W","City":"San Jose","State":"CA"},{"LatD":"37","LatM":"46","LatS":"47","NS":"N","LonD":"122","LonM":"25","LonS":"11","EW":"W","City":"San Francisco","State":"CA"},{"LatD":"41","LatM":"27","LatS":"0","NS":"N","LonD":"82","LonM":"42","LonS":"35","EW":"W","City":"Sandusky","State":"OH"},{"LatD":"32","LatM":"42","LatS":"35","NS":"N","LonD":"117","LonM":"9","LonS":"0","EW":"W","City":"San Diego","State":"CA"},{"LatD":"34","LatM":"6","LatS":"36","NS":"N","LonD":"117","LonM":"18","LonS":"35","EW":"W","City":"San Bernardino","State":"CA"},{"LatD":"29","LatM":"25","LatS":"12","NS":"N","LonD":"98","LonM":"30","LonS":"0","EW":"W","City":"San Antonio","State":"TX"},{"LatD":"31","LatM":"27","LatS":"35","NS":"N","LonD":"100","LonM":"26","LonS":"24","EW":"W","City":"San Angelo","State":"TX"},{"LatD":"40","LatM":"45","LatS":"35","NS":"N","LonD":"111","LonM":"52","LonS":"47","EW":"W","City":"Salt Lake City","State":"UT"},{"LatD":"38","LatM":"22","LatS":"11","NS":"N","LonD":"75","LonM":"35","LonS":"59","EW":"W","City":"Salisbury","State":"MD"},{"LatD":"36","LatM":"40","LatS":"11","NS":"N","LonD":"121","LonM":"39","LonS":"0","EW":"W","City":"Salinas","State":"CA"},{"LatD":"38","LatM":"50","LatS":"24","NS":"N","LonD":"97","LonM":"36","LonS":"36","EW":"W","City":"Salina","State":"KS"},{"LatD":"38","LatM":"31","LatS":"47","NS":"N","LonD":"106","LonM":"0","LonS":"0","EW":"W","City":"Salida","State":"CO"},{"LatD":"44","LatM":"56","LatS":"23","NS":"N","LonD":"123","LonM":"1","LonS":"47","EW":"W","City":"Salem","State":"OR"},{"LatD":"44","LatM":"57","LatS":"0","NS":"N","LonD":"93","LonM":"5","LonS":"59","EW":"W","City":"Saint Paul","State":"MN"},{"LatD":"38","LatM":"37","LatS":"11","NS":"N","LonD":"90","LonM":"11","LonS":"24","EW":"W","City":"Saint Louis","State":"MO"},{"LatD":"39","LatM":"46","LatS":"12","NS":"N","LonD":"94","LonM":"50","LonS":"23","EW":"W","City":"Saint Joseph","State":"MO"},{"LatD":"42","LatM":"5","LatS":"59","NS":"N","LonD":"86","LonM":"28","LonS":"48","EW":"W","City":"Saint Joseph","State":"MI"},{"LatD":"44","LatM":"25","LatS":"11","NS":"N","LonD":"72","LonM":"1","LonS":"11","EW":"W","City":"Saint Johnsbury","State":"VT"},{"LatD":"45","LatM":"34","LatS":"11","NS":"N","LonD":"94","LonM":"10","LonS":"11","EW":"W","City":"Saint Cloud","State":"MN"},{"LatD":"29","LatM":"53","LatS":"23","NS":"N","LonD":"81","LonM":"19","LonS":"11","EW":"W","City":"Saint Augustine","State":"FL"},{"LatD":"43","LatM":"25","LatS":"48","NS":"N","LonD":"83","LonM":"56","LonS":"24","EW":"W","City":"Saginaw","State":"MI"},{"LatD":"38","LatM":"35","LatS":"24","NS":"N","LonD":"121","LonM":"29","LonS":"23","EW":"W","City":"Sacramento","State":"CA"},{"LatD":"43","LatM":"36","LatS":"36","NS":"N","LonD":"72","LonM":"58","LonS":"12","EW":"W","City":"Rutland","State":"VT"},{"LatD":"33","LatM":"24","LatS":"0","NS":"N","LonD":"104","LonM":"31","LonS":"47","EW":"W","City":"Roswell","State":"NM"},{"LatD":"35","LatM":"56","LatS":"23","NS":"N","LonD":"77","LonM":"48","LonS":"0","EW":"W","City":"Rocky Mount","State":"NC"},{"LatD":"41","LatM":"35","LatS":"24","NS":"N","LonD":"109","LonM":"13","LonS":"48","EW":"W","City":"Rock Springs","State":"WY"},{"LatD":"42","LatM":"16","LatS":"12","NS":"N","LonD":"89","LonM":"5","LonS":"59","EW":"W","City":"Rockford","State":"IL"},{"LatD":"43","LatM":"9","LatS":"35","NS":"N","LonD":"77","LonM":"36","LonS":"36","EW":"W","City":"Rochester","State":"NY"},{"LatD":"44","LatM":"1","LatS":"12","NS":"N","LonD":"92","LonM":"27","LonS":"35","EW":"W","City":"Rochester","State":"MN"},{"LatD":"37","LatM":"16","LatS":"12","NS":"N","LonD":"79","LonM":"56","LonS":"24","EW":"W","City":"Roanoke","State":"VA"},{"LatD":"37","LatM":"32","LatS":"24","NS":"N","LonD":"77","LonM":"26","LonS":"59","EW":"W","City":"Richmond","State":"VA"},{"LatD":"39","LatM":"49","LatS":"48","NS":"N","LonD":"84","LonM":"53","LonS":"23","EW":"W","City":"Richmond","State":"IN"},{"LatD":"38","LatM":"46","LatS":"12","NS":"N","LonD":"112","LonM":"5","LonS":"23","EW":"W","City":"Richfield","State":"UT"},{"LatD":"45","LatM":"38","LatS":"23","NS":"N","LonD":"89","LonM":"25","LonS":"11","EW":"W","City":"Rhinelander","State":"WI"},{"LatD":"39","LatM":"31","LatS":"12","NS":"N","LonD":"119","LonM":"48","LonS":"35","EW":"W","City":"Reno","State":"NV"},{"LatD":"50","LatM":"25","LatS":"11","NS":"N","LonD":"104","LonM":"39","LonS":"0","EW":"W","City":"Regina","State":"SA"},{"LatD":"40","LatM":"10","LatS":"48","NS":"N","LonD":"122","LonM":"14","LonS":"23","EW":"W","City":"Red Bluff","State":"CA"},{"LatD":"40","LatM":"19","LatS":"48","NS":"N","LonD":"75","LonM":"55","LonS":"48","EW":"W","City":"Reading","State":"PA"},{"LatD":"41","LatM":"9","LatS":"35","NS":"N","LonD":"81","LonM":"14","LonS":"23","EW":"W","City":"Ravenna","State":"OH "}] diff --git a/tests/test_csv_s.py b/tests/test_csv_s.py new file mode 100644 index 00000000..6bc75884 --- /dev/null +++ b/tests/test_csv_s.py @@ -0,0 +1,147 @@ +import os +import json +import unittest +import jc.parsers.csv_s + +THIS_DIR = os.path.dirname(os.path.abspath(__file__)) + + +# To create streaming output use: +# $ cat file.csv | jc --csv-s | jello -c > csv-file-streaming.json + + +class MyTests(unittest.TestCase): + + def setUp(self): + # input + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-biostats.csv'), 'r', encoding='utf-8') as f: + self.generic_csv_biostats = f.read() + + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-cities.csv'), 'r', encoding='utf-8') as f: + self.generic_csv_cities = f.read() + + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-deniro.csv'), 'r', encoding='utf-8') as f: + self.generic_csv_deniro = f.read() + + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-example.csv'), 'r', encoding='utf-8') as f: + self.generic_csv_example = f.read() + + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-flyrna.tsv'), 'r', encoding='utf-8') as f: + self.generic_csv_flyrna = f.read() + + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-flyrna2.tsv'), 'r', encoding='utf-8') as f: + self.generic_csv_flyrna2 = f.read() + + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-homes-pipe.csv'), 'r', encoding='utf-8') as f: + self.generic_csv_homes_pipe = f.read() + + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/csv-homes.csv'), 'r', encoding='utf-8') as f: + self.generic_csv_homes = f.read() + + 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() + + # 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()) + + 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-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-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-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-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-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-insurance-streaming.json'), 'r', encoding='utf-8') as f: + # self.generic_csv_insurance_json = json.loads(f.read()) + + def test_csv_s_nodata(self): + """ + Test CSV parser with no data + """ + self.assertEqual(list(jc.parsers.csv_s.parse('', quiet=True)), []) + + # no test for unparsable rows yet - CSV library fails right away if it can't decode the data + # def test_csv_unparsable(self): + # data = 'unparsable data' + # g = jc.parsers.csv_s.parse(data.splitlines(), quiet=True) + # 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 + """ + self.assertEqual(list(jc.parsers.csv_s.parse(self.generic_csv_biostats.splitlines(), quiet=True)), self.generic_csv_biostats_streaming_json) + + def test_csv_s_cities(self): + """ + Test 'cities.csv' file + """ + 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_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_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_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_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_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_insurance(self): + # """ + # Test 'insurance.csv' file + # """ + # self.assertEqual(jc.parsers.csv.parse(self.generic_csv_insurance, quiet=True), self.generic_csv_insurance_json) + + +if __name__ == '__main__': + unittest.main()