本文整理汇总了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()
示例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):
#.........这里部分代码省略.........
示例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)