<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> import datetime <EOL> import logging <EOL> import pytz <EOL> from django import test <EOL> from services . common import serialization , helpers as db_tools <EOL> class TestSerialization ( test . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . __verbose_testing = False <EOL> if not self . __verbose_testing : <EOL> logging . getLogger ( '<STR_LIT>' ) . setLevel ( level = logging . CRITICAL ) <EOL> self . __gs_1_id = '<STR_LIT>' <EOL> self . __gs_1_ch_1_id = '<STR_LIT>' <EOL> self . __band = db_tools . create_band ( ) <EOL> self . __user_profile = db_tools . create_user_profile ( ) <EOL> self . __gs = db_tools . create_gs ( <EOL> user_profile = self . __user_profile , identifier = self . __gs_1_id , <EOL> ) <EOL> self . __gs_1_ch_1 = db_tools . gs_add_channel ( <EOL> self . __gs , self . __band , self . __gs_1_ch_1_id <EOL> ) <EOL> def test_serialize_iso8601_date ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . __verbose_testing : <EOL> print ( '<STR_LIT>' ) <EOL> dt = datetime . datetime . now ( pytz . timezone ( '<STR_LIT>' ) ) <EOL> if dt . tzname ( ) == '<STR_LIT>' : <EOL> birthday = dt . replace ( <EOL> year = <NUM_LIT> , month = <NUM_LIT:7> , day = <NUM_LIT> , <EOL> hour = <NUM_LIT:0> , minute = <NUM_LIT:0> , second = <NUM_LIT:0> , microsecond = <NUM_LIT:0> <EOL> ) <EOL> expected = '<STR_LIT>' <EOL> else : <EOL> birthday = dt . replace ( <EOL> year = <NUM_LIT> , month = <NUM_LIT:7> , day = <NUM_LIT> , <EOL> hour = <NUM_LIT:0> , minute = <NUM_LIT:0> , second = <NUM_LIT:0> , microsecond = <NUM_LIT:0> <EOL> ) <EOL> expected = '<STR_LIT>' <EOL> actual = serialization . serialize_iso8601_date ( birthday ) <EOL> if self . __verbose_testing : <EOL> print ( '<STR_LIT>' + str ( expected ) ) <EOL> print ( '<STR_LIT>' + str ( actual ) ) <EOL> self . assertEqual ( actual , expected , '<STR_LIT>' ) <EOL> self . __verbose_testing = False <EOL> def test_deserialize_iso8601_date ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . __verbose_testing : <EOL> print ( '<STR_LIT>' ) <EOL> if datetime . datetime . now ( pytz . timezone ( '<STR_LIT>' ) ) . tzname ( ) == '<STR_LIT>' : <EOL> in_param = '<STR_LIT>' <EOL> expected = datetime . datetime . now ( <EOL> pytz . timezone ( '<STR_LIT>' ) <EOL> ) . replace ( <EOL> year = <NUM_LIT> , month = <NUM_LIT:7> , day = <NUM_LIT> , <EOL> hour = <NUM_LIT:0> , minute = <NUM_LIT:0> , second = <NUM_LIT:0> , microsecond = <NUM_LIT:0> <EOL> ) <EOL> else : <EOL> in_param = '<STR_LIT>' <EOL> expected = datetime . datetime . now ( <EOL> pytz . timezone ( '<STR_LIT>' ) <EOL> ) . replace ( <EOL> year = <NUM_LIT> , month = <NUM_LIT:7> , day = <NUM_LIT> , <EOL> hour = <NUM_LIT:0> , minute = <NUM_LIT:0> , second = <NUM_LIT:0> , microsecond = <NUM_LIT:0> <EOL> ) <EOL> actual = serialization . deserialize_iso8601_date ( in_param ) <EOL> if self . __verbose_testing : <EOL> print ( '<STR_LIT>' + str ( expected ) ) <EOL> print ( '<STR_LIT>' + str ( actual ) ) <EOL> self . assertEqual ( actual , expected , '<STR_LIT>' ) <EOL> self . __verbose_testing = False <EOL> def test_serialize_iso8601_time ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . __verbose_testing : <EOL> print ( '<STR_LIT>' ) <EOL> dt = datetime . datetime . now ( pytz . timezone ( '<STR_LIT>' ) ) <EOL> midnight = dt . replace ( hour = <NUM_LIT:0> , minute = <NUM_LIT:0> , second = <NUM_LIT:0> , microsecond = <NUM_LIT:0> ) <EOL> if midnight . tzname ( ) == '<STR_LIT>' : <EOL> expected = '<STR_LIT>' <EOL> else : <EOL> expected = '<STR_LIT>' <EOL> actual = serialization . serialize_iso8601_time ( midnight ) <EOL> if self . __verbose_testing : <EOL> print ( '<STR_LIT>' + str ( expected ) ) <EOL> print ( '<STR_LIT>' + str ( actual ) ) <EOL> self . assertEqual ( actual , expected , '<STR_LIT>' ) <EOL> def test_deserialize_iso8601_time ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . __verbose_testing : <EOL> print ( '<STR_LIT>' ) <EOL> if datetime . datetime . now ( pytz . timezone ( '<STR_LIT>' ) ) . tzname ( ) == '<STR_LIT>' : <EOL> in_param = '<STR_LIT>' <EOL> expected = '<STR_LIT>' <EOL> else : <EOL> in_param = '<STR_LIT>' <EOL> expected = '<STR_LIT>' <EOL> actual = serialization . deserialize_iso8601_time ( in_param ) <EOL> if self . __verbose_testing : <EOL> print ( '<STR_LIT>' + str ( expected ) ) <EOL> print ( '<STR_LIT>' + str ( actual ) ) <EOL> self . assertEqual ( <EOL> actual . isoformat ( ) , expected , '<STR_LIT>' <EOL> ) <EOL> self . __verbose_testing = False </s>
