def test_extract_datetime_byline_mmddyy_with_mdyy_format(): datetime_string = 'CHQ Staff | 12/17/18' format_string = 'M/D/YY' iso_string = extract_datetime_string(datetime_string, format_string) expected_iso_string = '2018-12-17T00:00:00' assert iso_string == expected_iso_string
def test_extract_datetime_byline_0m0dyy_with_mdyy_format(): datetime_string = 'CHQ Staff | 01/07/18' format_string = 'M/D/YY' iso_string = extract_datetime_string(datetime_string, format_string) expected_iso_string = '2018-01-07T00:00:00' assert iso_string == expected_iso_string
def test_extract_datetime_us_format_without_timezone(): datetime_string = '03/01/05' format_string = 'MM/DD/YY' iso_string = extract_datetime_string(datetime_string, format_string) expected_iso_string = '2005-03-01T00:00:00' assert iso_string == expected_iso_string
def test_extract_datetime_abcnews_variants(datetime_string, format_string, expected_iso_string): assert extract_datetime_string(datetime_string, format_string) == expected_iso_string
def test_extract_datetime_iso8601_drop_timezone(): datetime_string = '2014-10-24T17:32:46+12:00' iso_string = extract_datetime_string(datetime_string) expected_iso_string = '2014-10-24T17:32:46' assert iso_string == expected_iso_string
def test_extract_datetime_iso8601_keep_timezone_keep(): datetime_string = '2014-10-24T17:32:46+12:00' iso_string = extract_datetime_string(datetime_string, timezone=True) expected_iso_string = '2014-10-24T17:32:46+12:00' assert iso_string == expected_iso_string