当前位置: 首页>>代码示例>>Python>>正文


Python ExperimentACL.delete方法代码示例

本文整理汇总了Python中tardis.tardis_portal.models.ExperimentACL.delete方法的典型用法代码示例。如果您正苦于以下问题:Python ExperimentACL.delete方法的具体用法?Python ExperimentACL.delete怎么用?Python ExperimentACL.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tardis.tardis_portal.models.ExperimentACL的用法示例。


在下文中一共展示了ExperimentACL.delete方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testCantEditPublicExperiment

# 需要导入模块: from tardis.tardis_portal.models import ExperimentACL [as 别名]
# 或者: from tardis.tardis_portal.models.ExperimentACL import delete [as 别名]
    def testCantEditPublicExperiment(self):
        login = self.client3.login(username=self.user3.username, password='secret')
        self.assertTrue(login)

        # user3 has acl to write to experiment3
        acl = ExperimentACL(
            pluginId=django_user,
            entityId=str(self.user3.id),
            experiment=self.experiment3,
            canRead=True,
            canWrite=True,
            aclOwnershipType=ExperimentACL.OWNER_OWNED,
            )
        acl.save()

        response = self.client3.get('/experiment/edit/%i/' % (self.experiment3.id))
        self.assertEqual(response.status_code, 403)

        response = self.client3.post('/experiment/edit/%i/' % (self.experiment3.id),
                                     {'anything': True, })
        self.assertEqual(response.status_code, 403)

        acl.delete()
        self.client3.logout()
开发者ID:aaryani,项目名称:aa-migration-test1,代码行数:26,代码来源:test_authorisation.py

示例2: ViewTemplateContextsTest

# 需要导入模块: from tardis.tardis_portal.models import ExperimentACL [as 别名]
# 或者: from tardis.tardis_portal.models.ExperimentACL import delete [as 别名]
class ViewTemplateContextsTest(TestCase):

    def setUp(self):
        """
        setting up essential objects, copied from tests above
        """
        Location.force_initialize()
        self.location = Location.get_location('local')

        user = 'tardis_user1'
        pwd = 'secret'
        email = ''
        self.user = User.objects.create_user(user, email, pwd)
        self.userProfile = UserProfile(user=self.user)
        self.exp = Experiment(title='test exp1',
                              institution_name='monash', created_by=self.user)
        self.exp.save()
        self.acl = ExperimentACL(
            pluginId=django_user,
            entityId=str(self.user.id),
            experiment=self.exp,
            canRead=True,
            isOwner=True,
            aclOwnershipType=ExperimentACL.OWNER_OWNED,
            )
        self.acl.save()
        self.dataset = Dataset(description='dataset description...')
        self.dataset.save()
        self.dataset.experiments.add(self.exp)
        self.dataset.save()

        self.dataset_file = Dataset_File(dataset=self.dataset,
                                         size=42, filename="foo",
                                         md5sum="junk")
        self.dataset_file.save()
        self.replica = Replica(datafile=self.dataset_file,
                               url="http://foo",
                               location=self.location,
                               verified=False)
        self.replica.save()

    def tearDown(self):
        self.user.delete()
        self.exp.delete()
        self.dataset.delete()
        self.dataset_file.delete()
        self.acl.delete()
        
    def testExperimentView(self):
        """
        test some template context parameters for an experiment view
        """
        from tardis.tardis_portal.views import view_experiment
        from tardis.tardis_portal.shortcuts import render_response_index
        from django.http import HttpRequest
        from django.template import Context
        import sys

        # Default behavior
        views_module = flexmock(sys.modules['tardis.tardis_portal.views'])
        request = HttpRequest()
        request.user=self.user
        request.groups=[]
        context = {'organization': ['classic', 'test', 'test2'],
                   'default_organization': 'classic', 
                   'default_format': 'zip', 
                   'protocol': [['zip', '/download/experiment/1/zip/'], 
                                ['tar', '/download/experiment/1/tar/']]}
        views_module.should_call('render_response_index'). \
            with_args(_AnyMatcher(), "tardis_portal/view_experiment.html", 
                      _ContextMatcher(context)) 
        response = view_experiment(request, experiment_id=self.exp.id)
        self.assertEqual(response.status_code, 200)

        # Behavior with USER_AGENT_SENSING enabled and a request.user_agent
        saved_setting = getattr(settings, "USER_AGENT_SENSING", None)
        try:
            setattr(settings, "USER_AGENT_SENSING", True)
            request = HttpRequest()
            request.user=self.user
            request.groups=[]
            mock_agent = _MiniMock(os=_MiniMock(family="Macintosh"))
            setattr(request, 'user_agent', mock_agent);
            context = {'organization': ['classic', 'test', 'test2'],
                       'default_organization': 'classic', 
                       'default_format': 'tar', 
                       'protocol': [['tar', '/download/experiment/1/tar/']]}
            views_module.should_call('render_response_index'). \
                with_args(_AnyMatcher(), "tardis_portal/view_experiment.html", 
                          _ContextMatcher(context)) 
            response = view_experiment(request, experiment_id=self.exp.id)
            self.assertEqual(response.status_code, 200)
        finally:
            if saved_setting != None:
                setattr(settings, "USER_AGENT_SENSING", saved_setting)
            else:
                delattr(settings, "USER_AGENT_SENSING")
            

    def testDatasetView(self):
#.........这里部分代码省略.........
开发者ID:guillaumeprevost,项目名称:mytardis,代码行数:103,代码来源:test_views.py

示例3: ContextualViewTest

# 需要导入模块: from tardis.tardis_portal.models import ExperimentACL [as 别名]
# 或者: from tardis.tardis_portal.models.ExperimentACL import delete [as 别名]
class ContextualViewTest(TestCase):

    def setUp(self):
        """
        setting up essential objects, copied from tests above
        """
        user = 'tardis_user1'
        pwd = 'secret'
        email = ''
        self.user = User.objects.create_user(user, email, pwd)
        self.userProfile = UserProfile(user=self.user)
        self.exp = Experiment(title='test exp1',
                              institution_name='monash', created_by=self.user)
        self.exp.save()
        self.acl = ExperimentACL(
            pluginId=django_user,
            entityId=str(self.user.id),
            experiment=self.exp,
            canRead=True,
            isOwner=True,
            aclOwnershipType=ExperimentACL.OWNER_OWNED,
            )
        self.acl.save()
        self.dataset = Dataset(description='dataset description...')
        self.dataset.save()
        self.dataset.experiments.add(self.exp)
        self.dataset.save()

        self.dataset_file = Dataset_File(dataset=self.dataset,
                                         size=42, filename="foo",
                                         md5sum="junk")
        self.dataset_file.save()

        self.testschema = Schema(namespace="http://test.com/test/schema",
                                 name="Test View",
                                 type=Schema.DATAFILE,
                                 hidden=True)
        self.testschema.save()
        self.dfps = DatafileParameterSet(dataset_file=self.dataset_file,
                                         schema=self.testschema)
        self.dfps.save()

    def tearDown(self):
        self.user.delete()
        self.exp.delete()
        self.dataset.delete()
        self.dataset_file.delete()
        self.testschema.delete()
        self.dfps.delete()
        self.acl.delete()
        
    def testDetailsDisplay(self):
        """
        test display of view for an existing schema and no display for an undefined one.
        """
        from tardis.tardis_portal.views import display_datafile_details
        request = flexmock(user=self.user, groups=[("testgroup",flexmock())])
        with self.settings(DATAFILE_VIEWS=[("http://test.com/test/schema", "/test/url"),
                                           ("http://does.not.exist", "/false/url")]):
            response = display_datafile_details(request, dataset_file_id=self.dataset_file.id)
            self.assertEqual(response.status_code, 200)
            self.assertTrue("/ajax/parameters/" in response.content)
            self.assertTrue("/test/url" in response.content)
            self.assertFalse("/false/url" in response.content)
开发者ID:guillaumeprevost,项目名称:mytardis,代码行数:66,代码来源:test_views.py


注:本文中的tardis.tardis_portal.models.ExperimentACL.delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。