def test_cast_weird_strings_to_date(self): # Mimic Spark behavior self.assertEqual( cast_to_date("2019-10-0001Tthis should be ignored", StringType(), options=BASE_OPTIONS), datetime.date(2019, 10, 1))
def test_cast_date_as_string_to_date(self): self.assertEqual( cast_to_date("2019-03-01", StringType(), options=BASE_OPTIONS), datetime.date(2019, 3, 1))
def test_cast_date_without_0_as_string_to_date(self): self.assertEqual( cast_to_date("2019-4-1", StringType(), options=BASE_OPTIONS), datetime.date(2019, 4, 1))
def test_cast_year_month_as_string_to_date(self): self.assertEqual( cast_to_date("2019-02", StringType(), options=BASE_OPTIONS), datetime.date(2019, 2, 1))