<s> from datetime import date , datetime <EOL> from . test_commons import * <EOL> from vertica_python import errors <EOL> from vertica_python . vertica . column import timestamp_parse <EOL> class DateParsingTestCase ( VerticaTestCase ) : <EOL> """<STR_LIT>""" <EOL> def _query_to_date ( self , expression , pattern ) : <EOL> return self . query_and_fetchall ( "<STR_LIT>" % locals ( ) ) <EOL> def _assert_date ( self , expression , pattern , expected ) : <EOL> res = self . _query_to_date ( expression , pattern ) <EOL> if len ( res ) == <NUM_LIT:0> : <EOL> self . fail ( "<STR_LIT>" % locals ( ) ) <EOL> elif len ( res [ <NUM_LIT:0> ] ) == <NUM_LIT:0> : <EOL> self . fail ( "<STR_LIT>" <EOL> % locals ( ) ) <EOL> self . assertEqual ( expected , res [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , "<STR_LIT>" % ( str ( expected ) , str ( res [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] ) ) ) <EOL> def test_after_christ ( self ) : <EOL> self . _assert_date ( '<STR_LIT>' , '<STR_LIT>' , date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> self . _assert_date ( '<STR_LIT>' , '<STR_LIT>' , date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> self . _assert_date ( '<STR_LIT>' , '<STR_LIT>' , date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> def test_before_christ_bc_indicator ( self ) : <EOL> try : <EOL> res = self . _query_to_date ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . fail ( "<STR_LIT>" + str ( res ) ) <EOL> except errors . NotSupportedError : <EOL> pass <EOL> def test_before_christ_ad_indicator ( self ) : <EOL> try : <EOL> res = self . _query_to_date ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . fail ( "<STR_LIT>" + str ( res ) ) <EOL> except errors . NotSupportedError : <EOL> pass <EOL> class TimestampParsingTestCase ( VerticaTestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_timestamp_parser ( self ) : <EOL> parsed_timestamp = timestamp_parse ( '<STR_LIT>' ) <EOL> self . assertEqual ( datetime ( year = <NUM_LIT> , month = <NUM_LIT:5> , day = <NUM_LIT:5> , hour = <NUM_LIT> , minute = <NUM_LIT:7> , second = <NUM_LIT> ) , parsed_timestamp ) <EOL> def test_timestamp_with_year_over_9999 ( self ) : <EOL> parsed_timestamp = timestamp_parse ( '<STR_LIT>' ) <EOL> self . assertEqual ( datetime ( year = <NUM_LIT> , month = <NUM_LIT:5> , day = <NUM_LIT:5> , hour = <NUM_LIT> , minute = <NUM_LIT:7> , second = <NUM_LIT> ) , parsed_timestamp ) <EOL> def test_timestamp_with_year_over_9999_and_ms ( self ) : <EOL> parsed_timestamp = timestamp_parse ( '<STR_LIT>' ) <EOL> self . assertEqual ( datetime ( year = <NUM_LIT> , month = <NUM_LIT:5> , day = <NUM_LIT:5> , hour = <NUM_LIT> , minute = <NUM_LIT:7> , second = <NUM_LIT> , microsecond = <NUM_LIT:3> ) , parsed_timestamp ) </s>
