示例#1
0
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"))
示例#2
0
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"))