<s> __author__ = '<STR_LIT>' <EOL> import unittest <EOL> from gdata import test_data <EOL> import atom <EOL> import gdata . contacts <EOL> class ContactEntryTest ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . entry = gdata . contacts . ContactEntryFromString ( test_data . NEW_CONTACT ) <EOL> def testParsingTestEntry ( self ) : <EOL> self . assertEquals ( self . entry . title . text , '<STR_LIT>' ) <EOL> self . assertEquals ( len ( self . entry . email ) , <NUM_LIT:2> ) <EOL> for email in self . entry . email : <EOL> if email . rel == '<STR_LIT>' : <EOL> self . assertEquals ( email . address , '<STR_LIT>' ) <EOL> elif email . rel == '<STR_LIT>' : <EOL> self . assertEquals ( email . address , '<STR_LIT>' ) <EOL> self . assertEquals ( len ( self . entry . phone_number ) , <NUM_LIT:3> ) <EOL> self . assertEquals ( len ( self . entry . postal_address ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( self . entry . postal_address [ <NUM_LIT:0> ] . primary , '<STR_LIT:true>' ) <EOL> self . assertEquals ( self . entry . postal_address [ <NUM_LIT:0> ] . text , <EOL> '<STR_LIT>' ) <EOL> self . assertEquals ( len ( self . entry . im ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( len ( self . entry . group_membership_info ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( self . entry . group_membership_info [ <NUM_LIT:0> ] . href , <EOL> '<STR_LIT>' ) <EOL> self . assertEquals ( self . entry . group_membership_info [ <NUM_LIT:0> ] . deleted , '<STR_LIT:false>' ) <EOL> self . assertEquals ( len ( self . entry . extended_property ) , <NUM_LIT:2> ) <EOL> self . assertEquals ( self . entry . extended_property [ <NUM_LIT:0> ] . name , '<STR_LIT>' ) <EOL> self . assertEquals ( self . entry . extended_property [ <NUM_LIT:0> ] . value , '<STR_LIT>' ) <EOL> self . assertEquals ( self . entry . extended_property [ <NUM_LIT:1> ] . name , '<STR_LIT>' ) <EOL> self . assertEquals ( <EOL> self . entry . extended_property [ <NUM_LIT:1> ] . GetXmlBlobExtensionElement ( ) . tag , <EOL> '<STR_LIT>' ) <EOL> def testToAndFromString ( self ) : <EOL> copied_entry = gdata . contacts . ContactEntryFromString ( str ( self . entry ) ) <EOL> self . assertEquals ( copied_entry . title . text , '<STR_LIT>' ) <EOL> self . assertEquals ( len ( copied_entry . email ) , <NUM_LIT:2> ) <EOL> for email in copied_entry . email : <EOL> if email . rel == '<STR_LIT>' : <EOL> self . assertEquals ( email . address , '<STR_LIT>' ) <EOL> elif email . rel == '<STR_LIT>' : <EOL> self . assertEquals ( email . address , '<STR_LIT>' ) <EOL> self . assertEquals ( len ( copied_entry . phone_number ) , <NUM_LIT:3> ) <EOL> self . assertEquals ( len ( copied_entry . postal_address ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( copied_entry . postal_address [ <NUM_LIT:0> ] . primary , '<STR_LIT:true>' ) <EOL> self . assertEquals ( copied_entry . postal_address [ <NUM_LIT:0> ] . text , <EOL> '<STR_LIT>' ) <EOL> self . assertEquals ( len ( copied_entry . im ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( len ( copied_entry . group_membership_info ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( copied_entry . group_membership_info [ <NUM_LIT:0> ] . href , <EOL> '<STR_LIT>' ) <EOL> self . assertEquals ( copied_entry . group_membership_info [ <NUM_LIT:0> ] . deleted , '<STR_LIT:false>' ) <EOL> self . assertEquals ( len ( copied_entry . extended_property ) , <NUM_LIT:2> ) <EOL> self . assertEquals ( copied_entry . extended_property [ <NUM_LIT:0> ] . name , '<STR_LIT>' ) <EOL> self . assertEquals ( copied_entry . extended_property [ <NUM_LIT:0> ] . value , '<STR_LIT>' ) <EOL> self . assertEquals ( copied_entry . extended_property [ <NUM_LIT:1> ] . name , '<STR_LIT>' ) <EOL> self . assertEquals ( <EOL> copied_entry . extended_property [ <NUM_LIT:1> ] . GetXmlBlobExtensionElement ( ) . tag , <EOL> '<STR_LIT>' ) <EOL> def testCreateContactFromScratch ( self ) : <EOL> new_entry = gdata . contacts . ContactEntry ( ) <EOL> new_entry . title = atom . Title ( text = '<STR_LIT>' ) <EOL> new_entry . content = atom . Content ( text = '<STR_LIT>' ) <EOL> new_entry . email . append ( gdata . contacts . Email ( <EOL> rel = '<STR_LIT>' , <EOL> address = '<STR_LIT>' ) ) <EOL> new_entry . phone_number . append ( gdata . contacts . PhoneNumber ( <EOL> rel = '<STR_LIT>' , text = '<STR_LIT>' ) ) <EOL> new_entry . organization = gdata . contacts . Organization ( <EOL> org_name = gdata . contacts . OrgName ( text = '<STR_LIT>' ) ) <EOL> new_entry . extended_property . append ( gdata . ExtendedProperty ( name = '<STR_LIT:test>' , <EOL> value = '<STR_LIT>' ) ) <EOL> new_entry . birthday = gdata . contacts . Birthday ( when = '<STR_LIT>' ) <EOL> sports_property = gdata . ExtendedProperty ( name = '<STR_LIT>' ) <EOL> sports_property . SetXmlBlob ( '<STR_LIT>' ) <EOL> new_entry . extended_property . append ( sports_property ) <EOL> entry_copy = gdata . contacts . ContactEntryFromString ( str ( new_entry ) ) <EOL> self . assertEquals ( entry_copy . title . text , new_entry . title . text ) <EOL> self . assertEquals ( entry_copy . content . text , '<STR_LIT>' ) <EOL> self . assertEquals ( len ( entry_copy . email ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( entry_copy . email [ <NUM_LIT:0> ] . rel , new_entry . email [ <NUM_LIT:0> ] . rel ) <EOL> self . assertEquals ( entry_copy . email [ <NUM_LIT:0> ] . address , '<STR_LIT>' ) <EOL> self . assertEquals ( len ( entry_copy . phone_number ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( entry_copy . phone_number [ <NUM_LIT:0> ] . rel , <EOL> new_entry . phone_number [ <NUM_LIT:0> ] . rel ) <EOL> self . assertEquals ( entry_copy . birthday . when , '<STR_LIT>' ) <EOL> self . assertEquals ( entry_copy . phone_number [ <NUM_LIT:0> ] . text , '<STR_LIT>' ) <EOL> self . assertEquals ( entry_copy . organization . org_name . text , '<STR_LIT>' ) <EOL> self . assertEquals ( len ( entry_copy . extended_property ) , <NUM_LIT:2> ) <EOL> self . assertEquals ( entry_copy . extended_property [ <NUM_LIT:0> ] . name , '<STR_LIT:test>' ) <EOL> self . assertEquals ( entry_copy . extended_property [ <NUM_LIT:0> ] . value , '<STR_LIT>' ) <EOL> class ContactsFeedTest ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . feed = gdata . contacts . ContactsFeedFromString ( test_data . CONTACTS_FEED ) <EOL> def testParsingTestFeed ( self ) : <EOL> self . assertEquals ( self . feed . id . text , <EOL> '<STR_LIT>' ) <EOL> self . assertEquals ( self . feed . title . text , '<STR_LIT>' ) <EOL> self . assertEquals ( self . feed . total_results . text , '<STR_LIT:1>' ) <EOL> self . assertEquals ( len ( self . feed . entry ) , <NUM_LIT:1> ) <EOL> self . assert_ ( isinstance ( self . feed . entry [ <NUM_LIT:0> ] , gdata . contacts . ContactEntry ) ) <EOL> self . assertEquals ( self . feed . entry [ <NUM_LIT:0> ] . GetPhotoLink ( ) . href , <EOL> '<STR_LIT>' ) <EOL> self . assertEquals ( self . feed . entry [ <NUM_LIT:0> ] . GetPhotoEditLink ( ) . href , <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> def testToAndFromString ( self ) : <EOL> copied_feed = gdata . contacts . ContactsFeedFromString ( str ( self . feed ) ) <EOL> self . assertEquals ( copied_feed . id . text , <EOL> '<STR_LIT>' ) <EOL> self . assertEquals ( copied_feed . title . text , '<STR_LIT>' ) <EOL> self . assertEquals ( copied_feed . total_results . text , '<STR_LIT:1>' ) <EOL> self . assertEquals ( len ( copied_feed . entry ) , <NUM_LIT:1> ) <EOL> self . assert_ ( isinstance ( copied_feed . entry [ <NUM_LIT:0> ] , gdata . contacts . ContactEntry ) ) <EOL> class GroupsFeedTest ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . feed = gdata . contacts . GroupsFeedFromString ( <EOL> test_data . CONTACT_GROUPS_FEED ) <EOL> def testParsingGroupsFeed ( self ) : <EOL> self . assertEquals ( self . feed . id . text , '<STR_LIT>' ) <EOL> self . assertEquals ( self . feed . title . text , '<STR_LIT>' ) <EOL> self . assertEquals ( self . feed . total_results . text , '<STR_LIT:3>' ) <EOL> self . assertEquals ( len ( self . feed . entry ) , <NUM_LIT:1> ) <EOL> self . assert_ ( isinstance ( self . feed . entry [ <NUM_LIT:0> ] , gdata . contacts . GroupEntry ) ) <EOL> class GroupEntryTest ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . entry = gdata . contacts . GroupEntryFromString ( <EOL> test_data . CONTACT_GROUP_ENTRY ) <EOL> def testParsingTestEntry ( self ) : <EOL> self . assertEquals ( self . entry . title . text , '<STR_LIT>' ) <EOL> self . assertEquals ( len ( self . entry . extended_property ) , <NUM_LIT:1> ) <EOL> self . assertEquals ( self . entry . extended_property [ <NUM_LIT:0> ] . name , <EOL> '<STR_LIT>' ) <EOL> self . assertEquals ( <EOL> self . entry . extended_property [ <NUM_LIT:0> ] . GetXmlBlobExtensionElement ( ) . namespace , <EOL> atom . ATOM_NAMESPACE ) <EOL> self . assertEquals ( <EOL> self . entry . extended_property [ <NUM_LIT:0> ] . GetXmlBlobExtensionElement ( ) . tag , <EOL> '<STR_LIT:info>' ) <EOL> self . assertEquals ( <EOL> self . entry . extended_property [ <NUM_LIT:0> ] . GetXmlBlobExtensionElement ( ) . text , <EOL> '<STR_LIT>' ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
