本文整理匯總了Python中MaKaC.conference.Conference.getContribsMatchingAuth方法的典型用法代碼示例。如果您正苦於以下問題:Python Conference.getContribsMatchingAuth方法的具體用法?Python Conference.getContribsMatchingAuth怎麽用?Python Conference.getContribsMatchingAuth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MaKaC.conference.Conference
的用法示例。
在下文中一共展示了Conference.getContribsMatchingAuth方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: TestAuthorSearch
# 需要導入模塊: from MaKaC.conference import Conference [as 別名]
# 或者: from MaKaC.conference.Conference import getContribsMatchingAuth [as 別名]
class TestAuthorSearch(unittest.TestCase):
"""Tests the author search
"""
def setUp( self ):
self._creator = Avatar()
self._creator.setId("creator")
self._conf=Conference(self._creator)
self._conf.setTimezone('UTC')
def testBasicSearch(self):
c1=Contribution()
self._conf.addContribution(c1)
auth1,auth2=ContributionParticipation(),ContributionParticipation()
auth1.setFamilyName("a")
auth1.setFirstName("a")
auth2.setFamilyName("b")
auth2.setFirstName("b")
c1.addPrimaryAuthor(auth1)
c1.addPrimaryAuthor(auth2)
self.assert_(len(self._conf.getContribsMatchingAuth(""))==1)
self.assert_(len(self._conf.getContribsMatchingAuth("a"))==1)
self.assert_(c1 in self._conf.getContribsMatchingAuth("a"))
self.assert_(c1 in self._conf.getContribsMatchingAuth("B"))
self.assert_(len(self._conf.getContribsMatchingAuth("B"))==1)
auth3=ContributionParticipation()
auth3.setFamilyName("c")
auth3.setFirstName("c")
c1.addCoAuthor(auth3)
self.assert_(len(self._conf.getContribsMatchingAuth(""))==1)
self.assert_(len(self._conf.getContribsMatchingAuth("c"))==0)
def testAddAuthor(self):
c1=Contribution()
self._conf.addContribution(c1)
auth1,auth2=ContributionParticipation(),ContributionParticipation()
auth1.setFamilyName("a")
auth1.setFirstName("a")
auth2.setFamilyName("b")
auth2.setFirstName("b")
c1.addPrimaryAuthor(auth1)
self.assert_(len(self._conf.getContribsMatchingAuth(""))==1)
self.assert_(len(self._conf.getContribsMatchingAuth("a"))==1)
self.assert_(c1 in self._conf.getContribsMatchingAuth("a"))
c1.addPrimaryAuthor(auth2)
self.assert_(len(self._conf.getContribsMatchingAuth("b"))==1)
self.assert_(c1 in self._conf.getContribsMatchingAuth("b"))
c1.removePrimaryAuthor(auth1)
self.assert_(len(self._conf.getContribsMatchingAuth(""))==1)
self.assert_(len(self._conf.getContribsMatchingAuth("a"))==0)
self.assert_(c1 not in self._conf.getContribsMatchingAuth("a"))
self.assert_(len(self._conf.getContribsMatchingAuth("b"))==1)
self.assert_(c1 in self._conf.getContribsMatchingAuth("b"))
def testWithdrawnContrib(self):
#Withdrawn contributions authors must be searchable
c1=Contribution()
self._conf.addContribution(c1)
auth1=ContributionParticipation()
auth1.setFamilyName("a")
auth1.setFirstName("a")
c1.addPrimaryAuthor(auth1)
c1.withdraw(self._creator,"ll")
self.assert_(len(self._conf.getContribsMatchingAuth(""))==1)
self.assert_(len(self._conf.getContribsMatchingAuth("a"))==1)
self.assert_(c1 in self._conf.getContribsMatchingAuth("a"))
auth2=ContributionParticipation()
auth2.setFamilyName("b")
auth2.setFirstName("b")
c1.addPrimaryAuthor(auth2)
#self._conf.getContribsMatchingAuth("b")
#self.assert_(len(self._conf.getContribsMatchingAuth(""))==1)
#self.assert_(len(self._conf.getContribsMatchingAuth("b"))==1)
#self.assert_(c1 in self._conf.getContribsMatchingAuth("b"))
def testAuthorsWithSameName(self):
#one contribution could have 2 authors with the same name
c1=Contribution()
self._conf.addContribution(c1)
auth1=ContributionParticipation()
auth1.setFamilyName("a")
auth1.setFirstName("a")
c1.addPrimaryAuthor(auth1)
auth2=ContributionParticipation()
auth2.setFamilyName("a")
auth2.setFirstName("a")
c1.addPrimaryAuthor(auth2)
self.assert_(len(self._conf.getContribsMatchingAuth(""))==1)
self.assert_(len(self._conf.getContribsMatchingAuth("a"))==1)
self.assert_(c1 in self._conf.getContribsMatchingAuth("a"))
c1.removePrimaryAuthor(auth1)
self.assert_(len(self._conf.getContribsMatchingAuth(""))==1)
self.assert_(len(self._conf.getContribsMatchingAuth("a"))==1)
self.assert_(c1 in self._conf.getContribsMatchingAuth("a"))