1+ from codonPython .check_null import check_null
2+ import numpy as np
3+ import pandas as pd
4+ import pytest
5+
6+ testdata = pd .DataFrame ({
7+ "col1" : [1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ],
8+ "col2" : [11 ,12 ,13 ,14 ,15 ,np .nan ,np .nan ,18 ,19 ,20 ],
9+ })
10+
11+ @pytest .mark .parametrize ("dataframe, columns_to_be_checked, expected" , [
12+ (testdata .iloc [:5 , :], ["col1" , "col2" ], 0 ),
13+ (testdata , ["col2" ], 2 ),
14+ ])
15+ def test_BAU (dataframe , columns_to_be_checked , expected ):
16+ assert check_null (dataframe , columns_to_be_checked ) == expected
17+
18+
19+ @pytest .mark .parametrize ("dataframe, columns_to_be_checked" , [
20+ (testdata , 0.01 ),
21+ ])
22+ def test_ValueError (dataframe , columns_to_be_checked ):
23+ with pytest .raises (ValueError ):
24+ check_null (dataframe , columns_to_be_checked )
25+
26+
27+ @pytest .mark .parametrize ("dataframe, columns_to_be_checked" , [
28+ (testdata , ["wrong_column" ]),
29+ ])
30+ def test_KeyError (dataframe , columns_to_be_checked ):
31+ with pytest .raises (KeyError ):
32+ check_null (dataframe , columns_to_be_checked )
0 commit comments