<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> from viewfinder . backend . db . identity import Identity <EOL> from viewfinder . backend . db . user import User <EOL> from viewfinder . backend . www . test import service_base_test <EOL> class ResolveContactsTestCase ( service_base_test . ServiceBaseTestCase ) : <EOL> def setUp ( self ) : <EOL> super ( ResolveContactsTestCase , self ) . setUp ( ) <EOL> user , _ = self . _tester . RegisterFakeViewfinderUser ( { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } ) <EOL> self . phone_user_id = user . user_id <EOL> def _Resolve ( self , identities ) : <EOL> response = self . _SendRequest ( '<STR_LIT>' , self . _cookie , <EOL> { '<STR_LIT>' : identities } ) <EOL> return response [ '<STR_LIT>' ] <EOL> def testOne ( self ) : <EOL> """<STR_LIT>""" <EOL> users = self . _Resolve ( [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( users , [ { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : self . _user . user_id , <EOL> '<STR_LIT:name>' : self . _user . name , <EOL> '<STR_LIT>' : self . _user . given_name , <EOL> '<STR_LIT>' : [ User . REGISTERED ] } ] ) <EOL> def testMissing ( self ) : <EOL> """<STR_LIT>""" <EOL> users = self . _Resolve ( [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( users , [ { '<STR_LIT>' : '<STR_LIT>' } ] ) <EOL> def testPhone ( self ) : <EOL> """<STR_LIT>""" <EOL> users = self . _Resolve ( [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( users , [ { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : self . phone_user_id , <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ User . REGISTERED ] } ] ) <EOL> def testFacebook ( self ) : <EOL> """<STR_LIT>""" <EOL> users = self . _Resolve ( [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( users , [ { '<STR_LIT>' : '<STR_LIT>' } ] ) <EOL> def testMultiple ( self ) : <EOL> """<STR_LIT>""" <EOL> users = self . _Resolve ( [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] ) <EOL> self . assertEqual ( users , [ { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : self . _user . user_id , <EOL> '<STR_LIT:name>' : self . _user . name , <EOL> '<STR_LIT>' : self . _user . given_name , <EOL> '<STR_LIT>' : [ User . REGISTERED ] } , <EOL> { '<STR_LIT>' : '<STR_LIT>' } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : self . phone_user_id , <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ User . REGISTERED ] } , <EOL> { '<STR_LIT>' : '<STR_LIT>' } ] ) <EOL> def testUnboundIdentity ( self ) : <EOL> """<STR_LIT>""" <EOL> identity_key = '<STR_LIT>' <EOL> self . _UpdateOrAllocateDBObject ( Identity , key = identity_key ) <EOL> users = self . _Resolve ( [ identity_key ] ) <EOL> self . assertEqual ( users , [ { u'<STR_LIT>' : identity_key } ] ) <EOL> def testNonCanonicalId ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertRaisesHttpError ( <NUM_LIT> , self . _Resolve , [ '<STR_LIT>' ] ) <EOL> def testTerminatedUser ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _validate = False <EOL> users = self . _Resolve ( [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( users , [ { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : self . _user3 . user_id , <EOL> '<STR_LIT:name>' : self . _user3 . name , <EOL> '<STR_LIT>' : [ User . REGISTERED ] } ] ) <EOL> self . _tester . TerminateAccount ( self . _cookie3 ) <EOL> users = self . _Resolve ( [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( users , [ { '<STR_LIT>' : '<STR_LIT>' } ] ) <EOL> def testProspectiveUser ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _CreateSimpleTestAssets ( ) <EOL> new_user , _ , _ = self . _CreateProspectiveUser ( ) <EOL> users = self . _Resolve ( [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( users , [ { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:5> , <EOL> '<STR_LIT>' : [ ] } ] ) <EOL> self . _UpdateOrAllocateDBObject ( User , <EOL> user_id = new_user . user_id , <EOL> labels = [ User . REGISTERED ] ) <EOL> users = self . _Resolve ( [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( users , [ { '<STR_LIT>' : new_user . user_id , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ User . REGISTERED ] } ] ) </s>
