

def test_as_contributor(self):
    admin = UserFactory.create()
    contributor = UserFactory.create()
    other = UserFactory.create()
    project = ProjectFactory.create(add_admins=[admin], add_contributors=[contributor], add_viewer=[other])
    ref = Project.objects.as_contributor(admin, project.id)
    self.assertEqual(project, ref)
    ref = Project.objects.as_contributor(contributor, project.id)
    self.assertEqual(project, ref)
    try:
        Project.objects.as_contributor(other, project.id)
    except PermissionDenied:
        pass
    else:
        self.fail('PermissionDenied not raise for non contributor')

dataset/ETHPy150Open ExCiteS/geokey/geokey/projects/tests/test_managers.py ProjectAccessTest.test_as_contributor/original