~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/soyuz/tests/test_archive.py

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
from lp.services.propertycache import clear_property_cache
38
38
from lp.services.worlddata.interfaces.country import ICountrySet
39
39
from lp.soyuz.enums import (
 
40
    ArchivePermissionType,
40
41
    ArchivePurpose,
41
42
    ArchiveStatus,
42
43
    PackagePublishingStatus,
60
61
from lp.soyuz.interfaces.component import IComponentSet
61
62
from lp.soyuz.interfaces.processor import IProcessorFamilySet
62
63
from lp.soyuz.model.archive import Archive
 
64
from lp.soyuz.model.archivepermission import ArchivePermission
63
65
from lp.soyuz.model.binarypackagerelease import (
64
66
    BinaryPackageReleaseDownloadCount,
65
67
    )
67
69
from lp.soyuz.tests.test_publishing import SoyuzTestPublisher
68
70
from lp.testing import (
69
71
    ANONYMOUS,
 
72
    celebrity_logged_in,
70
73
    login,
71
74
    login_person,
72
75
    person_logged_in,
824
827
            False,
825
828
            archive.canUploadSuiteSourcePackage(person, suitesourcepackage))
826
829
 
 
830
    def test_hasAnyPermission(self):
 
831
        # hasAnyPermission returns true if the person is the member of a
 
832
        # team with any kind of permission on the archive.
 
833
        archive = self.factory.makeArchive()
 
834
        person = self.factory.makePerson()
 
835
        team = self.factory.makeTeam()
 
836
        main = getUtility(IComponentSet)["main"]
 
837
        ArchivePermission(
 
838
            archive=archive, person=team, component=main,
 
839
            permission=ArchivePermissionType.UPLOAD)
 
840
 
 
841
        self.assertFalse(archive.hasAnyPermission(person))
 
842
        with celebrity_logged_in('admin'):
 
843
            team.addMember(person, team.teamowner)
 
844
        self.assertTrue(archive.hasAnyPermission(person))
 
845
 
827
846
 
828
847
class TestUpdatePackageDownloadCount(TestCaseWithFactory):
829
848
    """Ensure that updatePackageDownloadCount works as expected."""