def test_dictify_returns_dict(): result = schools.dictify(schools.closest("JAKE")) assert isinstance(result, list) result = schools.dictify(schools.exact("Shepaug Valley School")) assert isinstance(result, list)
def test_jsonify_returns_json(): result = schools.jsonify(schools.closest("JAKE")) assert isinstance(json.loads(result), list) result = schools.jsonify(schools.exact("Shepaug Valley School")) assert isinstance(json.loads(result), list)
import ct_schools.schools as schools print "-" * 20 print "FIND THE CLOSEST MATCH" print schools.closest("Shepau Vall") print "-" * 20 print "FIND THE CLOSEST 3 MATCHES" print schools.closest("Shepaug Valley School",lim=3) print "-" * 20 print "FIND AN EXACT (CASE-INSENSITIVE) MATCH" print schools.exact("Shepaug Valley School") print "-" * 20 print "FIND ALL MATCHES WITH A FUZZ RATIO ABOVE 80" print schools.fuzzy("Shepaug Valley School", ratio=80)
def test_exact_fail_rasies_exception(): with pytest.raises(Exception): schools.exact("FAKE FAKE SCHOOL")
def test_exact_success_returns_dataframe(): assert isinstance(schools.exact("SHEPAUG VALLEY SCHOOL"), pd.DataFrame)