<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> import time <EOL> import unittest <EOL> from functools import partial <EOL> from viewfinder . backend . base import util <EOL> from viewfinder . backend . base . testing import async_test <EOL> from viewfinder . backend . db . device import Device <EOL> from base_test import DBBaseTestCase <EOL> class DeviceTestCase ( DBBaseTestCase ) : <EOL> @ async_test <EOL> def testInvalidToken ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _mobile_dev . push_token = '<STR_LIT>' <EOL> self . _mobile_dev . Update ( self . _client , self . _OnDeviceUpdate ) <EOL> def _OnDeviceUpdate ( self ) : <EOL> """<STR_LIT>""" <EOL> Device . PushNotification ( self . _client , self . _user . user_id , '<STR_LIT>' , <NUM_LIT:1> , <EOL> partial ( self . _QueryUntilPushTokenNone , <NUM_LIT:0> , self . _mobile_dev ) ) <EOL> def _QueryUntilPushTokenNone ( self , count , device ) : <EOL> """<STR_LIT>""" <EOL> MAX_RETRIES = <NUM_LIT:5> <EOL> assert count < MAX_RETRIES <EOL> if device . push_token is None : <EOL> self . assertIsNone ( device . alert_user_id ) <EOL> self . stop ( ) <EOL> else : <EOL> query_cb = partial ( Device . Query , self . _client , self . _user . user_id , <EOL> self . _mobile_dev . device_id , None , <EOL> partial ( self . _QueryUntilPushTokenNone , count + <NUM_LIT:1> ) ) <EOL> self . io_loop . add_timeout ( time . time ( ) + <NUM_LIT> , query_cb ) <EOL> def testRepr ( self ) : <EOL> device = Device . CreateFromKeywords ( user_id = <NUM_LIT:1> , device_id = <NUM_LIT:1> , os = '<STR_LIT>' , name = '<STR_LIT>' ) <EOL> self . assertIn ( '<STR_LIT>' , repr ( device ) ) <EOL> self . assertNotIn ( '<STR_LIT>' , repr ( device ) ) <EOL> def testCreate ( self ) : <EOL> self . assertRaises ( KeyError , Device . CreateFromKeywords , user_id = <NUM_LIT:1> , device_id = <NUM_LIT:2> , device_uuid = '<STR_LIT:foo>' ) <EOL> self . assertRaises ( KeyError , Device . CreateFromKeywords , user_id = <NUM_LIT:1> , device_id = <NUM_LIT:2> , test_udid = '<STR_LIT:bar>' ) <EOL> device = Device . Create ( user_id = <NUM_LIT:1> , device_id = <NUM_LIT:1> , os = '<STR_LIT>' , name = '<STR_LIT>' , device_uuid = '<STR_LIT:foo>' , test_udid = '<STR_LIT:bar>' ) <EOL> self . assertIn ( '<STR_LIT>' , repr ( device ) ) <EOL> self . assertNotIn ( '<STR_LIT>' , repr ( device ) ) <EOL> self . assertNotIn ( '<STR_LIT>' , repr ( device ) ) <EOL> self . assertNotIn ( '<STR_LIT>' , repr ( device ) ) <EOL> self . assertRaises ( KeyError , device . UpdateFromKeywords , user_id = <NUM_LIT:1> , device_id = <NUM_LIT:1> , <EOL> os = '<STR_LIT>' , device_uuid = '<STR_LIT:foo>' , test_udid = '<STR_LIT:bar>' ) <EOL> device . UpdateFields ( user_id = <NUM_LIT:1> , device_id = <NUM_LIT:1> , os = '<STR_LIT>' , device_uuid = '<STR_LIT:foo>' ) <EOL> self . assertIn ( '<STR_LIT>' , repr ( device ) ) <EOL> self . assertNotIn ( '<STR_LIT>' , repr ( device ) ) <EOL> self . assertNotIn ( '<STR_LIT>' , repr ( device ) ) <EOL> self . assertNotIn ( '<STR_LIT>' , repr ( device ) ) </s>
