def test_make_page_title(self, user_patch, vault_patch):
        def _pt(id, title=None):
            return dict(id=id.lower(), title=title or id)

        user_inst = {'user_name': 'John Doe'}
        module_inst = {'module_group_name': 'neutron'}

        self.assertEqual('OpenStack community contribution in all releases',
                         helpers.make_page_title(
                             _pt('OpenStack'), 'all', None, None, None))
        self.assertEqual('OpenStack community contribution in Havana release',
                         helpers.make_page_title(
                             _pt('OpenStack'), 'Havana', None, None, None))
        self.assertEqual('Mirantis contribution in Havana release',
                         helpers.make_page_title(
                             _pt('Stackforge'), 'Havana', None, 'Mirantis',
                             None))
        self.assertEqual('John Doe contribution in Havana release',
                         helpers.make_page_title(
                             _pt('all'), 'Havana', None, None, user_inst))
        self.assertEqual(
            'John Doe (Mirantis) contribution to neutron in Havana release',
            helpers.make_page_title(
                _pt('all'), 'Havana', module_inst, 'Mirantis', user_inst))
        self.assertEqual('Ansible community contribution during OpenStack '
                         'Havana release',
                         helpers.make_page_title(
                             _pt('Ansible'), 'Havana', None, None, None))
        self.assertEqual('Docker community contribution',
                         helpers.make_page_title(
                             _pt('Docker'), 'all', None, None, None))
Exemple #2
0
    def test_make_page_title(self, user_patch, vault_patch):
        def _pt(id, title=None):
            return dict(id=id.lower(), title=title or id)

        user_inst = {'user_name': 'John Doe'}
        module_inst = {'module_group_name': 'neutron'}

        self.assertEqual(
            'OpenStack community contribution in all releases',
            helpers.make_page_title(_pt('OpenStack'), 'all', None, None, None))
        self.assertEqual(
            'OpenStack community contribution in Havana release',
            helpers.make_page_title(_pt('OpenStack'), 'Havana', None, None,
                                    None))
        self.assertEqual(
            'Mirantis contribution in Havana release',
            helpers.make_page_title(_pt('Stackforge'), 'Havana', None,
                                    'Mirantis', None))
        self.assertEqual(
            'John Doe contribution in Havana release',
            helpers.make_page_title(_pt('all'), 'Havana', None, None,
                                    user_inst))
        self.assertEqual(
            'John Doe (Mirantis) contribution to neutron in Havana release',
            helpers.make_page_title(_pt('all'), 'Havana', module_inst,
                                    'Mirantis', user_inst))
        self.assertEqual(
            'Ansible community contribution during OpenStack '
            'Havana release',
            helpers.make_page_title(_pt('Ansible'), 'Havana', None, None,
                                    None))
        self.assertEqual(
            'Docker community contribution',
            helpers.make_page_title(_pt('Docker'), 'all', None, None, None))
    def test_make_page_title(self, user_patch, vault_patch):
        user_inst = {'user_name': 'John Doe'}
        module_inst = {'module_group_name': 'neutron'}

        self.assertEqual('OpenStack community contribution in all releases',
                         helpers.make_page_title('all', None, None, None))
        self.assertEqual('OpenStack community contribution in Havana release',
                         helpers.make_page_title('Havana', None, None, None))
        self.assertEqual(
            'Mirantis contribution in Havana release',
            helpers.make_page_title('Havana', None, 'Mirantis', None))
        self.assertEqual(
            'John Doe contribution in Havana release',
            helpers.make_page_title('Havana', None, None, user_inst))
        self.assertEqual(
            'John Doe (Mirantis) contribution to neutron in Havana release',
            helpers.make_page_title('Havana', module_inst, 'Mirantis',
                                    user_inst))
    def test_make_page_title(self, user_patch, vault_patch):
        user_inst = {'user_name': 'John Doe'}
        module_inst = {'module_group_name': 'neutron'}

        self.assertEqual('OpenStack community contribution in all releases',
                         helpers.make_page_title('all', None, None, None))
        self.assertEqual('OpenStack community contribution in Havana release',
                         helpers.make_page_title('Havana', None, None, None))
        self.assertEqual('Mirantis contribution in Havana release',
                         helpers.make_page_title(
                             'Havana', None, 'Mirantis', None))
        self.assertEqual('John Doe contribution in Havana release',
                         helpers.make_page_title(
                             'Havana', None, None, user_inst))
        self.assertEqual(
            'John Doe (Mirantis) contribution to neutron in Havana release',
            helpers.make_page_title(
                'Havana', module_inst, 'Mirantis', user_inst))
Exemple #5
0
    def test_make_page_title(self, user_patch, vault_patch):
        memory_storage_mock = mock.Mock()
        memory_storage_mock.get_original_company_name = mock.Mock(
            return_value='Mirantis')
        vault_patch.return_value = {'memory_storage': memory_storage_mock}
        user_patch.return_value = {'user_name': 'John Doe'}

        self.assertEqual('OpenStack community contribution in all releases',
                         helpers.make_page_title('', '', '', 'all'))
        self.assertEqual('OpenStack community contribution in Havana release',
                         helpers.make_page_title('', '', '', 'Havana'))
        self.assertEqual('Mirantis contribution in Havana release',
                         helpers.make_page_title('Mirantis', '', '', 'Havana'))
        self.assertEqual('John Doe contribution in Havana release',
                         helpers.make_page_title('', 'john_doe', '', 'Havana'))
        self.assertEqual(
            'John Doe (Mirantis) contribution to neutron in Havana release',
            helpers.make_page_title('Mirantis', 'John Doe', 'neutron',
                                    'Havana'))
Exemple #6
0
    def test_make_page_title(self, user_patch, vault_patch):
        memory_storage_mock = mock.Mock()
        memory_storage_mock.get_original_company_name = mock.Mock(
            return_value='Mirantis'
        )
        vault_patch.return_value = {'memory_storage': memory_storage_mock}
        user_patch.return_value = {'user_name': 'John Doe'}

        self.assertEqual('OpenStack community contribution in all releases',
                         helpers.make_page_title('', '', '', 'all'))
        self.assertEqual('OpenStack community contribution in Havana release',
                         helpers.make_page_title('', '', '', 'Havana'))
        self.assertEqual('Mirantis contribution in Havana release',
                         helpers.make_page_title('Mirantis', '', '', 'Havana'))
        self.assertEqual('John Doe contribution in Havana release',
                         helpers.make_page_title('', 'john_doe', '', 'Havana'))
        self.assertEqual(
            'John Doe (Mirantis) contribution to neutron in Havana release',
            helpers.make_page_title(
                'Mirantis', 'John Doe', 'neutron', 'Havana'))
Exemple #7
0
        def templated_decorated_function(*args, **kwargs):

            vault_inst = vault.get_vault()
            template_name = template
            if template_name is None:
                template_name = (flask.request.endpoint.replace('.', '/') +
                                 '.html')
            ctx = f(*args, **kwargs)
            if ctx is None:
                ctx = {}

            try:
                _prepare_params(kwargs, [])
            except Exception:
                if return_code == 200:
                    raise  # do not re-raise on error page

            # put parameters into template
            ctx['metric'] = parameters.get_single_parameter(kwargs,
                                                            'metric',
                                                            use_default=True)
            ctx['metric_label'] = parameters.METRIC_LABELS.get(ctx['metric'])

            project_type = parameters.get_single_parameter(kwargs,
                                                           'project_type',
                                                           use_default=True)
            ctx['project_type'] = project_type

            ctx['release'] = parameters.get_single_parameter(kwargs,
                                                             'release',
                                                             use_default=True)

            company = parameters.get_single_parameter(kwargs, 'company')
            ctx['company'] = company
            if company:
                ctx['company_original'] = (
                    vault.get_memory_storage().get_original_company_name(
                        ctx['company']))

            module = parameters.get_single_parameter(kwargs, 'module')
            ctx['module'] = module
            if module and module in vault_inst['module_id_index']:
                ctx['module_inst'] = vault_inst['module_id_index'][module]

            ctx['user_id'] = parameters.get_single_parameter(kwargs, 'user_id')
            if ctx['user_id']:
                ctx['user_inst'] = vault.get_user_from_runtime_storage(
                    ctx['user_id'])

            ctx['page_title'] = helpers.make_page_title(
                ctx.get('release'), ctx.get('module_inst'),
                ctx.get('company_original'), ctx.get('user_inst'))

            ctx['stackalytics_version'] = (
                stackalytics_version.version_info.version_string())
            ctx['stackalytics_release'] = (
                stackalytics_version.version_info.release_string())
            ctx['runtime_storage_update_time'] = (
                vault_inst['runtime_storage_update_time'])

            # deprecated -- top mentor report
            ctx['review_nth'] = parameters.get_single_parameter(
                kwargs, 'review_nth')

            return flask.render_template(template_name, **ctx), return_code
Exemple #8
0
        def templated_decorated_function(*args, **kwargs):

            vault_inst = vault.get_vault()
            template_name = template
            if template_name is None:
                template_name = (flask.request.endpoint.replace('.', '/') +
                                 '.html')
            ctx = f(*args, **kwargs)
            if ctx is None:
                ctx = {}

            # put parameters into template
            metric = flask.request.args.get('metric')
            if metric not in parameters.METRIC_LABELS:
                metric = None
            ctx['metric'] = metric or parameters.get_default('metric')
            ctx['metric_label'] = parameters.METRIC_LABELS[ctx['metric']]

            project_type = flask.request.args.get('project_type')
            if not vault.is_project_type_valid(project_type):
                project_type = parameters.get_default('project_type')
            ctx['project_type'] = project_type

            release = flask.request.args.get('release')
            releases = vault_inst['releases']
            if release:
                release = release.lower()
                if release != 'all':
                    if release not in releases:
                        release = None
                    else:
                        release = releases[release]['release_name']
            ctx['release'] = (release or
                              parameters.get_default('release')).lower()
            ctx['review_nth'] = (flask.request.args.get('review_nth') or
                                 parameters.get_default('review_nth'))

            ctx['company'] = parameters.get_single_parameter(kwargs, 'company')
            ctx['company_original'] = (
                vault.get_memory_storage().get_original_company_name(
                    ctx['company']))

            module = parameters.get_single_parameter(kwargs, 'module')
            ctx['module'] = module
            module_name = None
            if module and module in vault_inst['module_id_index']:
                ctx['module_inst'] = vault_inst['module_id_index'][module]
                module_name = ctx['module_inst']['module_group_name']

            ctx['user_id'] = parameters.get_single_parameter(kwargs, 'user_id')
            if ctx['user_id']:
                ctx['user_inst'] = vault.get_user_from_runtime_storage(
                    ctx['user_id'])
            ctx['page_title'] = helpers.make_page_title(
                ctx['company'], ctx['user_id'], module_name, ctx['release'])
            ctx['stackalytics_version'] = (
                stackalytics_version.version_info.version_string())
            ctx['stackalytics_release'] = (
                stackalytics_version.version_info.release_string())
            ctx['runtime_storage_update_time'] = (
                vault_inst['runtime_storage_update_time'])

            return flask.render_template(template_name, **ctx), return_code
        def templated_decorated_function(*args, **kwargs):

            vault_inst = vault.get_vault()
            template_name = template
            if template_name is None:
                template_name = (flask.request.endpoint.replace('.', '/') +
                                 '.html')
            ctx = f(*args, **kwargs)
            if ctx is None:
                ctx = {}

            try:
                _prepare_params(kwargs, [])
            except Exception:
                if return_code == 200:
                    raise  # do not re-raise on error page

            # put parameters into template
            ctx['metric'] = parameters.get_single_parameter(
                kwargs, 'metric', use_default=True)
            ctx['metric_label'] = parameters.METRIC_LABELS.get(ctx['metric'])

            project_type = parameters.get_single_parameter(
                kwargs, 'project_type', use_default=True)
            ctx['project_type'] = project_type
            ctx['project_type_inst'] = vault.get_project_type(project_type)

            ctx['release'] = parameters.get_single_parameter(
                kwargs, 'release', use_default=True)

            company = parameters.get_single_parameter(kwargs, 'company')
            ctx['company'] = company
            if company:
                ctx['company_original'] = (
                    vault.get_memory_storage().get_original_company_name(
                        ctx['company']))

            module = parameters.get_single_parameter(kwargs, 'module')
            ctx['module'] = module
            if module and module in vault_inst['module_id_index']:
                ctx['module_inst'] = vault_inst['module_id_index'][module]

            ctx['user_id'] = parameters.get_single_parameter(kwargs, 'user_id')
            if ctx['user_id']:
                ctx['user_inst'] = vault.get_user_from_runtime_storage(
                    ctx['user_id'])

            ctx['page_title'] = helpers.make_page_title(
                ctx['project_type_inst'],
                ctx.get('release'), ctx.get('module_inst'),
                ctx.get('company_original'), ctx.get('user_inst'))

            ctx['stackalytics_version'] = (
                stackalytics_version.version_info.version_string())
            ctx['stackalytics_release'] = (
                stackalytics_version.version_info.release_string())
            update_time = vault_inst['runtime_storage_update_time']
            ctx['runtime_storage_update_time'] = update_time
            ctx['runtime_storage_update_time_str'] = helpers.format_datetime(
                update_time) if update_time else None

            # deprecated -- top mentor report
            ctx['review_nth'] = parameters.get_single_parameter(
                kwargs, 'review_nth')

            return flask.render_template(template_name, **ctx), return_code
Exemple #10
0
        def templated_decorated_function(*args, **kwargs):

            vault_inst = vault.get_vault()
            template_name = template
            if template_name is None:
                template_name = (flask.request.endpoint.replace('.', '/') +
                                 '.html')
            ctx = f(*args, **kwargs)
            if ctx is None:
                ctx = {}

            # put parameters into template
            metric = flask.request.args.get('metric')
            if metric not in parameters.METRIC_LABELS:
                metric = None
            ctx['metric'] = metric or parameters.get_default('metric')
            ctx['metric_label'] = parameters.METRIC_LABELS[ctx['metric']]

            project_type = flask.request.args.get('project_type')
            if not vault.is_project_type_valid(project_type):
                project_type = parameters.get_default('project_type')
            ctx['project_type'] = project_type

            release = flask.request.args.get('release')
            releases = vault_inst['releases']
            if release:
                release = release.lower()
                if release != 'all':
                    if release not in releases:
                        release = None
                    else:
                        release = releases[release]['release_name']
            ctx['release'] = (release or
                              parameters.get_default('release')).lower()
            ctx['review_nth'] = (flask.request.args.get('review_nth') or
                                 parameters.get_default('review_nth'))

            ctx['company'] = parameters.get_single_parameter(kwargs, 'company')
            ctx['company_original'] = (
                vault.get_memory_storage().get_original_company_name(
                    ctx['company']))

            module = parameters.get_single_parameter(kwargs, 'module')
            ctx['module'] = module
            module_name = None
            if module and module in vault_inst['module_id_index']:
                ctx['module_inst'] = vault_inst['module_id_index'][module]
                module_name = ctx['module_inst']['module_group_name']

            ctx['user_id'] = parameters.get_single_parameter(kwargs, 'user_id')
            if ctx['user_id']:
                ctx['user_inst'] = vault.get_user_from_runtime_storage(
                    ctx['user_id'])
            ctx['page_title'] = helpers.make_page_title(
                ctx['company'], ctx['user_id'], module_name, ctx['release'])
            ctx['stackalytics_version'] = (
                stackalytics_version.version_info.version_string())
            ctx['stackalytics_release'] = (
                stackalytics_version.version_info.release_string())
            ctx['runtime_storage_update_time'] = (
                vault_inst['runtime_storage_update_time'])

            return flask.render_template(template_name, **ctx), return_code