def testContributorToAndFromString(self): self.contributor.name = atom.Name(text='J Scud') self.contributor.email = atom.Email(text='nobody@nowhere') self.contributor.uri = atom.Uri(text='http://www.google.com') self.assert_(self.contributor.name.text == 'J Scud') self.assert_(self.contributor.email.text == 'nobody@nowhere') self.assert_(self.contributor.uri.text == 'http://www.google.com') new_contributor = atom.ContributorFromString( self.contributor.ToString()) self.assert_(self.contributor.name.text == new_contributor.name.text) self.assert_(self.contributor.email.text == new_contributor.email.text) self.assert_(self.contributor.uri.text == new_contributor.uri.text)
def AddDoumail(self, receiverURI, subject, body): entry = douban.DoumailEntry() entry.entity.append( douban.Entity('receiver', "", extension_elements=[atom.Uri(text=receiverURI)])) entry.title = atom.Title(text=subject) entry.content = atom.Content(text=body) return self.Post(entry, '/doumails', converter=douban.DoumailEntryFromString)
def AddCaptchaDoumail(self, receiverURI, subject, body, captcha_token, captacha_string): entry = douban.DoumailEntry() entry.entity.append( douban.Entity('receiver', "", extension_elements=[atom.Uri(text=receiverURI)])) entry.title = atom.Title(text=subject) entry.content = atom.Content(text=body) entry.attribute = [] entry.attribute.append( douban.Attribute('captcha_string', captacha_string)) entry.attribute.append(douban.Attribute('captcha_token', captcha_token)) return self.Post(entry, '/doumails', converter=douban.DoumailEntryFromString)
def addDoumail(self, to, subject, body, captacha_token=None, captacha_string=None): entry = douban.DoumailEntry() receiverURI = "http://api.douban.com/people/%s" % to entry.entity.append( douban.Entity('receiver', "", extension_elements=[atom.Uri(text=receiverURI)])) entry.title = atom.Title(text=subject) entry.content = atom.Content(text=body) if captacha_token: entry.attribute.append( douban.Attribute('captacha_token', captacha_token)) if captacha_string: entry.attribute.append( douban.Attribute('captacha_string', captacha_string)) return self.__post("/doumails", entry.ToString())