def test_getColumnTest_Date_wrong_oneFormat(self): data = ["07-06-2020", "30/11/2019", "01/01/1992"] s = pd.Series(data, index=range(len(data))) self.assertFalse( getColumnTest(s, isValidDateFormat, "%d/%m/%Y").all(), "One is an invalid date by format '%d-%m-%Y', so must be False")
def test_getColumnTest_Date_wrong_allFormat(self): data = ["07-06-2020", "30-11-2019", "01-01-1992"] s = pd.Series(data, index=range(len(data))) self.assertFalse( getColumnTest(s, isValidDateFormat, "%d/%m/%Y").all(), "All is an invalid date by format '%d-%m-%Y'")
def test_getColumnTest_Date_wrong_one(self): data = ["09/02/2020", "04/01/2019", "06/30/1992"] s = pd.Series(data, index=range(len(data))) self.assertFalse( getColumnTest(s, isValidDateFormat, "%d/%m/%Y").all(), "One is an invalid date, so must be False")
def test_getColumnTest_Date_wrong_all(self): data = ["09/16/2020", "04/13/2019", "06/30/1992"] s = pd.Series(data, index=range(len(data))) self.assertFalse( getColumnTest(s, isValidDateFormat, "%d/%m/%Y").all(), "All is an invalid date")
def test_getColumnTest_Date_right_allNan(self): data = [np.nan, np.nan, np.nan] s = pd.Series(data, index=range(len(data))) self.assertTrue( getColumnTest(s, isValidDateFormat, "%d/%m/%Y").all(), "Even with all missing values, the Series is all right")
def test_getColumnTest_Date_right_withBlanks(self): data = [" 07/06/2020 ", " 30/11/2019", "01/01/1992 "] s = pd.Series(data, index=range(len(data))) self.assertTrue( getColumnTest(s, isValidDateFormat, "%d/%m/%Y").all(), "All is a valid date even with blanks (not trimmed yet)")