Exemplo n.º 1
0
 def test_isValidDateFormat_date_wrongFormat(self):
     #TODO: trovare un modo per convertire date (con format diverso)
     dt_str = "01-31-2020"
     dt_date = datetime.strptime(dt_str, "%m-%d-%Y")
     self.assertFalse(
         isValidDateFormat(dt_date, "%d/%m/%Y"),
         "datetime from format '%m-%d-%Y' ('01-31-2020') must be False")
Exemplo n.º 2
0
 def test_isValidDateFormat_string_wrong_differentFormat_extended(self):
     dt = "2020-01-31 00:00:00"
     self.assertFalse(isValidDateFormat(dt, "%d/%m/%Y"),
                      "String '2020-01-31 00:00:00' must be False")
Exemplo n.º 3
0
 def test_isValidDateFormat_date_right(self):
     dt_str = "31/01/2020"
     dt_date = datetime.strptime(dt_str, "%d/%m/%Y")
     self.assertTrue(isValidDateFormat(dt_date, "%d/%m/%Y"),
                     "Date '31/01/2020' must be True")
Exemplo n.º 4
0
 def test_isValidDateFormat_string_wrong_differentFormat(self):
     dt = "31-01-2020"
     self.assertFalse(isValidDateFormat(dt, "%d/%m/%Y"),
                      "String '31-01-2020' must be False")
Exemplo n.º 5
0
 def test_isValidDateFormat_string_wrong_yearFirst(self):
     dt = "2020/01/31"
     self.assertFalse(isValidDateFormat(dt, "%d/%m/%Y"),
                      "String '2020/01/31' must be False")
Exemplo n.º 6
0
 def test_isValidDateFormat_string_wrong_monthFirst(self):
     dt = "01/31/2020"
     self.assertFalse(isValidDateFormat(dt, "%d/%m/%Y"),
                      "String '01/31/2020' must be False")
Exemplo n.º 7
0
 def test_isValidDateFormat_nan_right(self):
     dt = np.nan
     self.assertTrue(isValidDateFormat(dt, "%d/%m/%Y"),
                     "String 'nan' must be True")
Exemplo n.º 8
0
 def test_isValidDateFormat_string_right(self):
     dt = "31/01/2020"
     self.assertTrue(isValidDateFormat(dt, "%d/%m/%Y"),
                     "String '31/01/2020' must be True")