当前位置: 首页>>代码示例>>Python>>正文


Python Conference.getContribsMatchingAuth方法代码示例

本文整理汇总了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"))
开发者ID:lukasnellen,项目名称:indico,代码行数:96,代码来源:testConferences.py


注:本文中的MaKaC.conference.Conference.getContribsMatchingAuth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。