本文整理汇总了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"))