<s> import datetime <EOL> from expects import * <EOL> from booby import encoders <EOL> CUSTOM_FORMAT = '<STR_LIT>' <EOL> INVALID_FORMAT = '<STR_LIT>' <EOL> IRRELEVANT_DATETIME = datetime . datetime ( <EOL> year = <NUM_LIT> , month = <NUM_LIT:2> , day = <NUM_LIT> , hour = <NUM_LIT:15> , minute = <NUM_LIT> , second = <NUM_LIT> ) <EOL> IRRELEVANT_DATETIME_IN_ISO = IRRELEVANT_DATETIME . isoformat ( ) <EOL> IRRELEVANT_DATETIME_IN_CUSTOM_FORMAT = IRRELEVANT_DATETIME . strftime ( CUSTOM_FORMAT ) <EOL> DATETIME_WITH_MICROSECOND = datetime . datetime ( <EOL> year = <NUM_LIT> , month = <NUM_LIT:2> , day = <NUM_LIT> , hour = <NUM_LIT:15> , minute = <NUM_LIT> , second = <NUM_LIT> , microsecond = <NUM_LIT> ) <EOL> DATETIME_WITH_MICROSECOND_IN_ISO = DATETIME_WITH_MICROSECOND . isoformat ( ) <EOL> class TestEncode ( object ) : <EOL> def test_should_return_datetime_string_in_iso_format ( self ) : <EOL> result = self . encoder ( IRRELEVANT_DATETIME ) <EOL> expect ( result ) . to ( equal ( IRRELEVANT_DATETIME_IN_ISO ) ) <EOL> def test_should_return_datetime_string_in_iso_format_with_microsecond ( self ) : <EOL> result = self . encoder ( DATETIME_WITH_MICROSECOND ) <EOL> expect ( result ) . to ( equal ( DATETIME_WITH_MICROSECOND_IN_ISO ) ) <EOL> def test_should_return_none_if_value_is_none ( self ) : <EOL> expect ( self . encoder ( None ) ) . to ( be_none ) <EOL> def test_should_return_datetime_string_in_given_format ( self ) : <EOL> self . encoder = encoders . DateTime ( CUSTOM_FORMAT ) <EOL> result = self . encoder ( IRRELEVANT_DATETIME ) <EOL> expect ( result ) . to ( equal ( IRRELEVANT_DATETIME_IN_CUSTOM_FORMAT ) ) <EOL> def setup ( self ) : <EOL> self . encoder = encoders . DateTime ( ) </s>
