Esempio n. 1
0
 def testProjectionPermissions(self, fixture):
     writer = self.writer(fixture)
     reader = self.reader(fixture)
     project = ProjectI()
     project.name = rstring("testProjectPermissions")
     project = writer.saveAndReturnObject(project)
     try:
         perms = unwrap(reader.projection(
             "select p.details.permissions from Project p where p.id = :id",
             ParametersI().addId(project.id.val)))[0][0]
     except IndexError:
         # No permissions were returned.
         assert not fixture.canRead
     else:
         self.assertPerms(perms, fixture)
 def testProjectionPermissions(self, fixture):
     writer = self.writer(fixture)
     reader = self.reader(fixture)
     project = ProjectI()
     project.name = rstring("testProjectPermissions")
     project = writer.saveAndReturnObject(project)
     try:
         perms = unwrap(
             reader.projection(
                 "select p.details.permissions from Project p where p.id = :id",
                 ParametersI().addId(project.id.val)))[0][0]
         assert fixture.canRead
     except IndexError:
         # No permissions were returned.
         assert not fixture.canRead
     else:
         self.assertPerms(perms, fixture)
    def test1069(self):
        unique = rstring(self.uuid())
        project = ProjectI()
        project.name = unique
        project.description = rstring("NOTME")
        project = self.client.sf.getUpdateService().saveAndReturnObject(project)
        self.index(project)

        search = self.client.sf.createSearchService()
        search.onlyType("Project")

        search.bySomeMustNone([unique.val], [], ["NOTME"])
        assert  not search.hasNext()

        search.bySomeMustNone([unique.val], [], ["NOTME","SOMETHINGELSE"])
        assert  not search.hasNext()

        search.bySomeMustNone([unique.val], [], [])
        assert  search.hasNext()
Esempio n. 4
0
    def test1069(self):
        unique = rstring(self.uuid())
        project = ProjectI()
        project.name = unique
        project.description = rstring("NOTME")
        project = self.client.sf.getUpdateService().saveAndReturnObject(project)
        self.index(project)

        search = self.client.sf.createSearchService()
        search.onlyType("Project")

        search.bySomeMustNone([unique.val], [], ["NOTME"])
        self.assert_( not search.hasNext() )

        search.bySomeMustNone([unique.val], [], ["NOTME","SOMETHINGELSE"])
        self.assert_( not search.hasNext() )

        search.bySomeMustNone([unique.val], [], [])
        self.assert_( search.hasNext() )
    def testProjectionPermissionsWorkaround(self, fixture):
        writer = self.writer(fixture)
        reader = self.reader(fixture)
        project = ProjectI()
        project.name = rstring("testProjectPermissions")
        project = writer.saveAndReturnObject(project)

        group = project.details.group.id.val
        owner = project.details.owner.id.val
        key = (group, owner)
        try:
            if key in self._cache:
                # In pytest, this is never actually reached,
                # since each test is a new instance, but this
                # would be the performance speed up needed in
                # clients. See #12474
                assert False
            else:
                proj = unwrap(
                    reader.projection(
                        "select p from Project p where p.id = :id",
                        ParametersI().addId(project.id.val),
                        {"omero:group": str(group)}))[0][0]
                assert fixture.canRead
                perms = proj.details.permissions
                value = {
                    "perms": str(perms),
                    "canAnnotate": perms.canAnnotate(),
                    "canDelete": perms.canDelete(),
                    "canEdit": perms.canEdit(),
                    "canLink": perms.canLink(),
                }
                self._cache[key] = value
        except IndexError:
            # No permissions were returned.
            assert not fixture.canRead
        else:
            self.assertPerms(self._cache[key], fixture)
Esempio n. 6
0
    def testProjectionPermissionsWorkaround(self, fixture):
        writer = self.writer(fixture)
        reader = self.reader(fixture)
        project = ProjectI()
        project.name = rstring("testProjectPermissions")
        project = writer.saveAndReturnObject(project)

        group = project.details.group.id.val
        owner = project.details.owner.id.val
        key = (group, owner)
        try:
            if key in self._cache:
                # In pytest, this is never actually reached,
                # since each test is a new instance, but this
                # would be the performance speed up needed in
                # clients. See #12474
                assert False
            else:
                proj = unwrap(reader.projection(
                    "select p from Project p where p.id = :id",
                    ParametersI().addId(project.id.val),
                    {"omero:group": str(group)}))[0][0]
                assert fixture.canRead
                perms = proj.details.permissions
                value = {
                    "perms": str(perms),
                    "canAnnotate": perms.canAnnotate(),
                    "canDelete": perms.canDelete(),
                    "canEdit": perms.canEdit(),
                    "canLink": perms.canLink(),
                }
                self._cache[key] = value
        except IndexError:
            # No permissions were returned.
            assert not fixture.canRead
        else:
            self.assertPerms(self._cache[key], fixture)
 def createProjectAs(self, user):
     """ Adds a Project. """
     project = ProjectI()
     project.name = rstring(user + "_" + self.proj_name)
     project = self.updateServices[user].saveAndReturnObject(project)
     return project
 def createProjectAs(self, user):
     """ Adds a Project. """
     project = ProjectI()
     project.name = rstring(user + "_" + self.proj_name)
     project = self.updateServices[user].saveAndReturnObject(project)
     return project