11from eda_utils_py import __version__
22from eda_utils_py import eda_utils_py
3+ from pytest import raises
34import pandas as pd
45
56def test_version ():
@@ -42,4 +43,41 @@ def test_cor_map():
4243 # Tests whether axes is using correct calculated var column as reference
4344 assert plot_dict ['layer' ][0 ]['encoding' ]['x' ]['field' ] == 'var1' , "x should be referring to var1"
4445 assert plot_dict ['layer' ][0 ]['encoding' ]['y' ]['field' ] == 'var2' , "y should be referring to var2"
45-
46+
47+
48+ # Testing the Exception Errors
49+ data2 = data .copy ().to_csv ()
50+
51+ num_col_test1 = (1 , 2 , 3 , 4 )
52+ num_col_test2 = [1 , 2 , 3 , 'SepalLengthCm' ]
53+ num_col_test3 = ['hi' , 'hey' , 'hi' ]
54+ num_col_test4 = ['SepalLengthCm' , 'SepalWidthCm' , 'PetalWidthCm' , 'Species' ]
55+ col_scheme_test = 3
56+
57+ # Tests whether data is not of dataframe raises TypeError
58+ with raises (TypeError ):
59+ eda_utils_py .cor_map (data2 , num_col_test )
60+
61+ # Tests whether num_col is of not type list raises TypeError
62+ with raises (TypeError ):
63+ eda_utils_py .cor_map (data , num_col_test1 )
64+
65+ # Tests whether contents of num_col is notof type str raises TypeError
66+ with raises (TypeError ):
67+ eda_utils_py .cor_map (data , num_col_test2 )
68+
69+ # Tests whether inputting unallowed col_scheme raises Exception
70+ with raises (Exception ):
71+ eda_utils_py .cor_map (data , num_col_test , 'bluegreen' )
72+
73+ # Tests whether inputting unallowed col_scheme raises TypeError
74+ with raises (TypeError ):
75+ eda_utils_py .cor_map (data , num_col_test , col_scheme_test )
76+
77+ # Tests whether columns do not exist in raises Exception
78+ with raises (Exception ):
79+ eda_utils_py .cor_map (data , num_col_test3 )
80+
81+ # Tests whether if not all columns in num_col is numeric raises Exception
82+ with raises (Exception ):
83+ eda_utils_py .cor_map (data , num_col_test4 )
0 commit comments