config = { "username": os.environ.get("TEST_USERNAME","*****@*****.**"), "password": os.environ["TEST_PASSWORD"], } test.configure(sink=config) google = test.get_sink().module #Log in try: google.refresh() ok("Logged in", google.loggedIn == True) except Exception, err: ok("Logged in (%s)" % err, False) #make a new contact with a random email address (so it doesnt conflict) contact = Contact.parse_vcf(vcfData % Utils.random_string())[0] test.do_dataprovider_tests( supportsGet=True, supportsDelete=True, safeLUID=SAFE_CONTACT_ID, data=contact, name="contact" ) #check we get a conflict if we put a contact with a known existing email address #FIXME: We should actually automatically resolve this conflict... contact = new_contact(None) try: google.put(contact, False) ok("Detected duplicate email", False) except Exceptions.SynchronizeConflictError:
EMAIL;TYPE=INTERNET:[email protected] END:VCARD BEGIN:VCARD VERSION:3.0 FN:STA Travel Canterbury Uni N:Uni;STA;Travel Canterbury;; EMAIL;TYPE=INTERNET:[email protected] END:VCARD""" c = Contact.Contact() ok("Created blank contact", len(c.get_vcard_string()) > 0) c = Contact.Contact(formattedName="Im Cool", givenName="Steve", familyName="Cool") ok("Created contact", len(c.get_vcard_string()) > 0) contacts = Contact.parse_vcf(vcfData) ok("Parsed vcf file (got %s vcards)" % len(contacts), len(contacts) == vcfData.count("BEGIN:VCARD")) c = contacts[-1] ok("Got vcard data", len(c.get_vcard_string()) > 0) ok("Got email addresses", len(c.get_emails()) > 0) ok("Got name", c.get_name() != None) #now add email addresses emails = ("*****@*****.**","baz@f") numb4 = len(c.get_emails()) c.set_emails(*emails) numAfta = len(c.get_emails()) ok("Added email addresses", numAfta == (numb4 | len(emails))) finished()