# Path: stackalytics/dashboard/helpers.py
# INFINITY_HTML = '&#x221E;'
# def _extend_author_fields(record):
# def _extend_record_common_fields(record):
# def _extend_by_parent_info(record, parent, prefix='parent_'):
# def extend_record(record):
# def get_current_company(user):
# def extend_user(user):
# def extend_module(module_id, project_type, release):
# def get_activity(records, start_record, page_size, query_message=None):
# def get_contribution_summary(records):
# def format_datetime(timestamp):
# def format_date(timestamp):
# def format_launchpad_module_link(module):
# def make_link(title, uri=None, options=None):
# def make_blueprint_link(module, name):
# def make_commit_message(record):
# def make_page_title(project_type_inst, release, module_inst, company,
#                     user_inst):
# def filter_bug_title(title):
# 
# Path: stackalytics/dashboard/parameters.py
# LOG = logging.getLogger(__name__)
# DEFAULTS = {
#     'review_nth': 5,
# }
# METRIC_LABELS = {
#     'loc': 'Lines of code',
#     'commits': 'Commits',
#     'marks': 'Reviews',
#     'emails': 'Emails',
#     'bpd': 'Drafted Blueprints',
#     'bpc': 'Completed Blueprints',
#     'filed-bugs': 'Filed Bugs',
#     'resolved-bugs': 'Resolved Bugs',
#     'person-day': "Person-day effort",
#     'ci': 'CI votes',
#     'patches': 'Patch Sets',
#     'translations': 'Translations',
# }
# METRIC_TO_RECORD_TYPE = {
#     'loc': ['commit'],
#     'commits': ['commit'],
#     'marks': ['mark'],
#     'emails': ['email'],
#     'bpd': ['bpd'],
#     'bpc': ['bpc'],
#     'filed-bugs': ['bugf'],
#     'resolved-bugs': ['bugr'],
#     'members': ['member'],
#     'person-day': ['mark', 'patch', 'email', 'bpd', 'bugf'],
#     'ci': ['ci'],
#     'patches': ['patch'],
#     'translations': ['tr'],
# }
# FILTER_PARAMETERS = ['release', 'project_type', 'module', 'company', 'user_id',
#                      'metric', 'start_date', 'end_date', 'blueprint_id',
#                      'core_in']
# DEFAULT_RECORDS_LIMIT = 10
# DEFAULT_STATIC_ACTIVITY_SIZE = 100
# def get_default(param_name):
# def get_parameter(kwargs, name, plural_name=None, use_default=True):
# def get_single_parameter(kwargs, name, use_default=True):


import mock
import testtools
from stackalytics.dashboard import helpers
from stackalytics.dashboard import parameters
    @mock.patch('flask.request')
    @mock.patch('stackalytics.dashboard.parameters.get_default')
    def test_parameters_get_parameter(self, get_default, flask_request):

        flask_request.args = mock.Mock()
        flask_request.args.get = mock.Mock(side_effect=lambda x: x)

        def make(values=None):
            def f(arg):
                return values.get(arg, None) if values else None
            return f

        get_default.side_effect = make()
        flask_request.args.get.side_effect = make({'param': 'foo'})
        self.assertEqual(['foo'], parameters.get_parameter(
            {'param': 'foo'}, 'param'))

        flask_request.args.get.side_effect = make({'param': 'foo'})
        self.assertEqual(['foo'], parameters.get_parameter({}, 'param'))

        flask_request.args.get.side_effect = make({'param': 'foo'})
        self.assertEqual([], parameters.get_parameter(
            {}, 'other', use_default=False))

        flask_request.args.get.side_effect = make({'params': 'foo'})
        self.assertEqual(['foo'], parameters.get_parameter(
            {}, 'param', plural_name='params'))

        flask_request.args.get.side_effect = make({})
        get_default.side_effect = make({'param': 'foo'})

# Path: stackalytics/dashboard/helpers.py
# INFINITY_HTML = '&#x221E;'
# def _extend_author_fields(record):
# def _extend_record_common_fields(record):
# def _extend_by_parent_info(record, parent, prefix='parent_'):
# def extend_record(record):
# def get_current_company(user):
# def extend_user(user):
# def extend_module(module_id, project_type, release):
# def get_activity(records, start_record, page_size, query_message=None):
# def get_contribution_summary(records):
# def format_datetime(timestamp):
# def format_date(timestamp):
# def format_launchpad_module_link(module):
# def make_link(title, uri=None, options=None):
# def make_blueprint_link(module, name):
# def make_commit_message(record):
# def make_page_title(project_type_inst, release, module_inst, company,
#                     user_inst):
# def filter_bug_title(title):
# 
# Path: stackalytics/dashboard/parameters.py
# LOG = logging.getLogger(__name__)
# DEFAULTS = {
#     'review_nth': 5,
# }
# METRIC_LABELS = {
#     'loc': 'Lines of code',
#     'commits': 'Commits',
#     'marks': 'Reviews',
#     'emails': 'Emails',
#     'bpd': 'Drafted Blueprints',
#     'bpc': 'Completed Blueprints',
#     'filed-bugs': 'Filed Bugs',
#     'resolved-bugs': 'Resolved Bugs',
#     'person-day': "Person-day effort",
#     'ci': 'CI votes',
#     'patches': 'Patch Sets',
#     'translations': 'Translations',
# }
# METRIC_TO_RECORD_TYPE = {
#     'loc': ['commit'],
#     'commits': ['commit'],
#     'marks': ['mark'],
#     'emails': ['email'],
#     'bpd': ['bpd'],
#     'bpc': ['bpc'],
#     'filed-bugs': ['bugf'],
#     'resolved-bugs': ['bugr'],
#     'members': ['member'],
#     'person-day': ['mark', 'patch', 'email', 'bpd', 'bugf'],
#     'ci': ['ci'],
#     'patches': ['patch'],
#     'translations': ['tr'],
# }
# FILTER_PARAMETERS = ['release', 'project_type', 'module', 'company', 'user_id',
#                      'metric', 'start_date', 'end_date', 'blueprint_id',
#                      'core_in']
# DEFAULT_RECORDS_LIMIT = 10
# DEFAULT_STATIC_ACTIVITY_SIZE = 100
# def get_default(param_name):
# def get_parameter(kwargs, name, plural_name=None, use_default=True):
# def get_single_parameter(kwargs, name, use_default=True):


# Path: stackalytics/tests/unit/test_web_utils.py
import mock
import testtools
from stackalytics.dashboard import helpers
from stackalytics.dashboard import parameters

    @mock.patch('flask.request')
    @mock.patch('stackalytics.dashboard.parameters.get_default')
    def test_parameters_get_parameter(self, get_default, flask_request):

        flask_request.args = mock.Mock()
        flask_request.args.get = mock.Mock(side_effect=lambda x: x)

        def make(values=None):
            def f(arg):
                return values.get(arg, None) if values else None
            return f

        get_default.side_effect = make()
        flask_request.args.get.side_effect = make({'param': 'foo'})
        self.assertEqual(['foo'], parameters.get_parameter(
            {'param': 'foo'}, 'param'))

        flask_request.args.get.side_effect = make({'param': 'foo'})
        self.assertEqual(['foo'], parameters.get_parameter({}, 'param'))

        flask_request.args.get.side_effect = make({'param': 'foo'})
        self.assertEqual([], parameters.get_parameter(
            {}, 'other', use_default=False))

        flask_request.args.get.side_effect = make({'params': 'foo'})
        self.assertEqual(['foo'], parameters.get_parameter(
            {}, 'param', plural_name='params'))

        flask_request.args.get.side_effect = make({})
        get_default.side_effect = make({'param': 'foo'})

        self.assertEqual(['foo'], parameters.get_parameter({}, 'param'))