示例#1
0
    def testExperimentView(self):
        """
        test some template context parameters for an experiment view
        """
        from tardis.tardis_portal.views import ExperimentView
        from django.http import HttpRequest
        import sys

        # Default behavior
        views_module = flexmock(sys.modules['tardis.tardis_portal.views'])
        request = HttpRequest()
        request.method = 'GET'
        request.user = self.user
        request.groups = []
        context = {
            'organization': ['test', 'test2'],
            'default_organization':
            'test',
            'default_format':
            'tar',
            'protocol': [['tgz', '/download/experiment/1/tgz/'],
                         ['tar', '/download/experiment/1/tar/']]
        }
        views_module.should_call('render_response_index'). \
            with_args(_AnyMatcher(), "tardis_portal/view_experiment.html",
                      _ContextMatcher(context))
        view_fn = ExperimentView.as_view()
        response = view_fn(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.method = 'GET'
            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))
            view_fn = ExperimentView.as_view()
            response = view_fn(request, experiment_id=self.exp.id)
            self.assertEqual(response.status_code, 200)
        finally:
            if saved_setting is not None:
                setattr(settings, "USER_AGENT_SENSING", saved_setting)
            else:
                delattr(settings, "USER_AGENT_SENSING")
示例#2
0
    def testExperimentView(self):
        """
        test some template context parameters for an experiment view
        """
        from tardis.tardis_portal.views import ExperimentView
        from django.http import HttpRequest
        import sys

        # Default behavior
        views_module = flexmock(sys.modules["tardis.tardis_portal.views"])
        request = HttpRequest()
        request.method = "GET"
        request.user = self.user
        request.groups = []
        context = {
            "organization": ["test", "test2"],
            "default_organization": "test",
            "default_format": "tar",
            "protocol": [["tgz", "/download/experiment/1/tgz/"], ["tar", "/download/experiment/1/tar/"]],
        }
        views_module.should_call("render_response_index").with_args(
            _AnyMatcher(), "tardis_portal/view_experiment.html", _ContextMatcher(context)
        )
        view_fn = ExperimentView.as_view()
        response = view_fn(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.method = "GET"
            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)
            )
            view_fn = ExperimentView.as_view()
            response = view_fn(request, experiment_id=self.exp.id)
            self.assertEqual(response.status_code, 200)
        finally:
            if saved_setting is not None:
                setattr(settings, "USER_AGENT_SENSING", saved_setting)
            else:
                delattr(settings, "USER_AGENT_SENSING")
示例#3
0
from tardis.tardis_portal.views import ExperimentView

from tardis.tardis_portal.views import (
    edit_experiment, create_experiment, add_experiment_access_user,
    remove_experiment_access_user, retrieve_access_list_user,
    retrieve_access_list_user_readonly, add_experiment_access_group,
    remove_experiment_access_group, retrieve_access_list_group,
    retrieve_access_list_group_readonly, create_user, create_group,
    retrieve_access_list_external, retrieve_access_list_tokens, create_token,
    view_rifcs, experiment_public_access_badge, add_dataset)

user_pattern = '[\w\-][\w\-\.]+(@[\w\-][\w\-\.]+[a-zA-Z]{1,4})*'

experiment_urls = [
    url(r'^view/(?P<experiment_id>\d+)/$',
        ExperimentView.as_view(),
        name='tardis_portal.view_experiment'),
    url(r'^edit/(?P<experiment_id>\d+)/$',
        edit_experiment,
        name='tardis.tardis_portal.views.edit_experiment'),
    url(r'^create/$',
        create_experiment,
        name='tardis.tardis_portal.views.create_experiment'),
    url(r'^control_panel/(?P<experiment_id>\d+)/access_list/add/user/'
        '(?P<username>%s)/$' % user_pattern,
        add_experiment_access_user,
        name='tardis.tardis_portal.views.add_experiment_access_user'),
    url(r'^control_panel/(?P<experiment_id>\d+)/access_list/remove/user/'
        '(?P<username>%s)/$' % user_pattern,
        remove_experiment_access_user,
        name='tardis.tardis_portal.views.remove_experiment_access_user'),
示例#4
0
experiment_lists = patterns(
    'tardis.tardis_portal.views',
    url(r'^$', 'experiment_index'),
    url(r'^/mine$', 'experiment_list_mine',
        name="tardis_portal.experiment_list_mine"),
    url(r'^/public$', 'experiment_list_public',
        name="tardis_portal.experiment_list_public"),
    url(r'^/shared$', 'experiment_list_shared',
        name="tardis_portal.experiment_list_shared"),
    )

user_pattern = '[\w\-][\w\-\.]+(@[\w\-][\w\-\.]+[a-zA-Z]{1,4})*'
experiment_urls = patterns(
    'tardis.tardis_portal.views',
    url(r'^view/(?P<experiment_id>\d+)/$', ExperimentView.as_view(),
        name='tardis_portal.view_experiment'),
    (r'^edit/(?P<experiment_id>\d+)/$', 'edit_experiment'),
    (r'^list', include(experiment_lists)),
    (r'^view/$', 'experiment_index'),  # Legacy URL
    (r'^create/$', 'create_experiment'),
    (r'^control_panel/(?P<experiment_id>\d+)/access_list/add/user/'
     '(?P<username>%s)/$' % user_pattern,
     'add_experiment_access_user'),
    (r'^control_panel/(?P<experiment_id>\d+)/access_list/remove/user/'
     '(?P<username>%s)/$' % user_pattern, 'remove_experiment_access_user'),
    (r'^control_panel/(?P<experiment_id>\d+)/access_list/change/user/'
     '(?P<username>%s)/$' % user_pattern, 'change_user_permissions'),
    (r'^control_panel/(?P<experiment_id>\d+)/access_list/user/$',
     'retrieve_access_list_user'),
    (r'^control_panel/(?P<experiment_id>\d+)/access_list/user/readonly/$',