def test_manageAffiliations_OnlyIgnoredAdmins(self, makeAffiliationsMock, getAffiliationsMock): getAffiliationsMock.side_effect = utils.good_side_effect({}) makeAffiliationsMock.side_effect = utils.good_side_effect('lush') sender = self.sender name = 'name' xsMock = Mock() d = sm.manageAffiliations(sender, name, [], [self.sender.full()], xsMock) def cb(msg): getAffiliationsMock.assert_called_once_with(sender=sender, node=name, xs=xsMock) self.assertEquals(makeAffiliationsMock.call_count, 0) d.addCallback(cb) return d
def test_manageAffiliations_includeAdmin(self, makeAffiliationsMock, getAffiliationsMock): getAffiliationsMock.side_effect = utils.good_side_effect({}) makeAffiliationsMock.side_effect = utils.good_side_effect('lush') sender = self.sender name = 'name' xsMock = Mock() d = sm.manageAffiliations(sender, name, [], [self.sender.full()], xsMock, True) def cb(msg): new_affiliations = {collab.ADMIN_JID: 'owner'} getAffiliationsMock.assert_called_once_with(sender=sender, node=name, xs=xsMock) makeAffiliationsMock.assert_called_once_with( sender=sender, node=name, affiliations=new_affiliations, xs=xsMock ) d.addCallback(cb) return d
def test_manageAffiliations_OnlyAdmins(self, makeAffiliationsMock, getAffiliationsMock): getAffiliationsMock.side_effect = utils.good_side_effect({}) makeAffiliationsMock.side_effect = utils.good_side_effect('lush') sender = self.sender name = 'name' xsMock = Mock() d = sm.manageAffiliations(sender, name, [], self.admins, xsMock) def cb(msg): new_affiliations = dict([(p, 'owner') for p in self.admins]) getAffiliationsMock.assert_called_once_with(sender=sender, node=name, xs=xsMock) makeAffiliationsMock.assert_called_once_with( sender=sender, node=name, affiliations=new_affiliations, xs=xsMock ) d.addCallback(cb) return d
def test_manageAffiliations_onlyOldAffiliations(self, makeAffiliationsMock, getAffiliationsMock): getAffiliationsMock.side_effect = utils.good_side_effect(self.old_affiliations) makeAffiliationsMock.side_effect = utils.good_side_effect('lush') sender = self.sender name = 'name' xsMock = Mock() d = sm.manageAffiliations(sender, name, [], [], xsMock) def cb(msg): getAffiliationsMock.assert_called_once_with(sender=sender, node=name, xs=xsMock) new_affiliations = { jid.JID('*****@*****.**').full(): 'none', jid.JID('*****@*****.**').full(): 'none', } makeAffiliationsMock.assert_called_once_with( sender=sender, node=name, affiliations=new_affiliations, xs=xsMock ) d.addCallback(cb) return d