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_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 pas_to_privacy(pas): """Converts a PersonalArchiveSubscription to privacy""" return IPrivacy(pas.archive)
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)