Example #1
0
 def private(self):
     """A view is private if its context is."""
     privacy = IPrivacy(self.context, None)
     if privacy is not None:
         return privacy.private
     else:
         return False
 def test_init(self):
     thing = ['any', 'thing']
     privacy = Privacy(thing, True)
     self.assertIs(True, IPrivacy.providedBy(privacy))
     self.assertIs(True, privacy.private)
     privacy = Privacy(thing, False)
     self.assertIs(False, privacy.private)
Example #3
0
 def test_personal_archive_subscription_adapts_to_privacy(self):
     owner = self.factory.makePerson(name='archiveowner')
     subscriber = self.factory.makePerson(name='subscriber')
     pppa = self.factory.makeArchive(owner=owner, private=True, name='pppa')
     with person_logged_in(owner):
         pppa.newSubscription(subscriber, owner)
     pas = PersonalArchiveSubscription(subscriber, pppa)
     privacy = IPrivacy(pas)
     self.assertTrue(privacy.private)
 def specs(self):
     if (IPrivacy.providedBy(self.context) and self.context.private
             and not check_permission('launchpad.View', self.context)):
         return []
     return self.context.specifications(self.user, filter=self.spec_filter)
def pas_to_privacy(pas):
    """Converts a PersonalArchiveSubscription to privacy"""
    return IPrivacy(pas.archive)
 def specs(self):
     if (IPrivacy.providedBy(self.context)
             and self.context.private
             and not check_permission('launchpad.View', self.context)):
         return []
     return self.context.specifications(self.user, filter=self.spec_filter)
 def test_forbidden_attribute(self):
     privacy = IPrivacy(ForbiddenAttribute('test'))
     self.assertIs(True, IPrivacy.providedBy(privacy))
     self.assertIs(True, privacy.private)
 def test_unauthorized(self):
     privacy = IPrivacy(Unauthorized('test'))
     self.assertIs(True, IPrivacy.providedBy(privacy))
     self.assertIs(True, privacy.private)
 def test_exception(self):
     privacy = IPrivacy(IndexError('test'))
     self.assertIs(True, IPrivacy.providedBy(privacy))
     self.assertIs(False, privacy.private)