<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> import time <EOL> import unittest <EOL> from viewfinder . backend . db . activity import Activity <EOL> from viewfinder . backend . db . asset_id import AssetIdUniquifier <EOL> from viewfinder . backend . db . comment import Comment <EOL> from viewfinder . backend . db . episode import Episode <EOL> from viewfinder . backend . db . operation import Operation <EOL> from viewfinder . backend . db . photo import Photo <EOL> from viewfinder . backend . db . viewpoint import Viewpoint <EOL> class IdTestCase ( unittest . TestCase ) : <EOL> _PRINT_RESULTS = False <EOL> def testActivityIds ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _TestIdRoundTripWithTimestamp ( Activity . ConstructActivityId , Activity . DeconstructActivityId ) <EOL> def testCommentIds ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _TestIdRoundTripWithTimestamp ( Comment . ConstructCommentId , Comment . DeconstructCommentId ) <EOL> def testEpisodeIds ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _TestIdRoundTripWithTimestamp ( Episode . ConstructEpisodeId , Episode . DeconstructEpisodeId ) <EOL> def testOperationIds ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _TestIdRoundTrip ( Operation . ConstructOperationId , Operation . DeconstructOperationId ) <EOL> def testPhotoIds ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _TestIdRoundTripWithTimestamp ( Photo . ConstructPhotoId , Photo . DeconstructPhotoId ) <EOL> def testViewpointIds ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _TestIdRoundTrip ( Viewpoint . ConstructViewpointId , Viewpoint . DeconstructViewpointId ) <EOL> def _TestIdRoundTripWithTimestamp ( self , construct , deconstruct ) : <EOL> """<STR_LIT>""" <EOL> def _RoundTrip ( timestamp , device_id , uniquifier ) : <EOL> asset_id = construct ( timestamp , device_id , uniquifier ) <EOL> actual_timestamp , actual_device_id , actual_uniquifier = deconstruct ( asset_id ) <EOL> self . assertEqual ( int ( timestamp ) , actual_timestamp ) <EOL> self . assertEqual ( device_id , actual_device_id ) <EOL> self . assertEqual ( uniquifier , actual_uniquifier ) <EOL> if IdTestCase . _PRINT_RESULTS : <EOL> print '<STR_LIT>' % ( ( timestamp , device_id , uniquifier ) , asset_id ) <EOL> _RoundTrip ( <NUM_LIT:0> , <NUM_LIT:0> , ( <NUM_LIT:0> , None ) ) <EOL> _RoundTrip ( <NUM_LIT> , <NUM_LIT> , ( <NUM_LIT> , None ) ) <EOL> _RoundTrip ( time . time ( ) , <NUM_LIT> , ( <NUM_LIT> , None ) ) <EOL> _RoundTrip ( time . time ( ) , <NUM_LIT> , ( <NUM_LIT> , None ) ) <EOL> _RoundTrip ( time . time ( ) , <NUM_LIT> , ( <NUM_LIT> , None ) ) <EOL> _RoundTrip ( <NUM_LIT:0> , <NUM_LIT:0> , ( <NUM_LIT:0> , '<STR_LIT>' ) ) <EOL> _RoundTrip ( <NUM_LIT> , <NUM_LIT> , ( <NUM_LIT> , '<STR_LIT>' ) ) <EOL> _RoundTrip ( time . time ( ) , <NUM_LIT> , ( <NUM_LIT> , u'<STR_LIT:1>' ) ) <EOL> _RoundTrip ( time . time ( ) , <NUM_LIT> , ( <NUM_LIT> , '<STR_LIT:U+0020>' ) ) <EOL> def _TestIdRoundTrip ( self , construct , deconstruct ) : <EOL> """<STR_LIT>""" <EOL> def _RoundTrip ( device_id , device_local_id ) : <EOL> server_id = construct ( device_id , device_local_id ) <EOL> actual_device_id , actual_device_local_id = deconstruct ( server_id ) <EOL> self . assertEqual ( device_id , actual_device_id ) <EOL> self . assertEqual ( device_local_id , actual_device_local_id ) <EOL> if IdTestCase . _PRINT_RESULTS : <EOL> print '<STR_LIT>' % ( ( device_id , device_local_id ) , server_id ) <EOL> _RoundTrip ( <NUM_LIT:0> , ( <NUM_LIT:0> , None ) ) <EOL> _RoundTrip ( <NUM_LIT> , ( <NUM_LIT> , None ) ) <EOL> _RoundTrip ( <NUM_LIT> , ( <NUM_LIT> , None ) ) <EOL> _RoundTrip ( <NUM_LIT> , ( <NUM_LIT> , None ) ) <EOL> _RoundTrip ( <NUM_LIT> , ( <NUM_LIT> , None ) ) <EOL> _RoundTrip ( <NUM_LIT:0> , ( <NUM_LIT:0> , '<STR_LIT>' ) ) <EOL> _RoundTrip ( <NUM_LIT> , ( <NUM_LIT> , '<STR_LIT>' ) ) <EOL> _RoundTrip ( <NUM_LIT> , ( <NUM_LIT> , u'<STR_LIT:1>' ) ) <EOL> _RoundTrip ( <NUM_LIT> , ( <NUM_LIT> , '<STR_LIT:U+0020>' ) ) </s>
