# Path: monasca_api/v2/reference/helpers.py
# LOG = log.getLogger(__name__)
# CONF = conf.CONF
# def from_json(req):
# def to_json(data):
# def validate_json_content_type(req):
# def validate_authorization(http_request, authorized_rules_list):
# def validate_payload_size(content_length):
# def get_x_tenant_or_tenant_id(http_request, delegate_authorized_rules_list):
# def get_query_param(req, param_name, required=False, default_val=None):
# def get_query_name(req, name_required=False):
# def get_query_dimensions(req, param_key='dimensions'):
# def get_query_starttime_timestamp(req, required=True):
# def get_query_endtime_timestamp(req, required=True):
# def validate_start_end_timestamps(start_timestamp, end_timestamp=None):
# def _convert_time_string(date_time_string):
# def get_query_statistics(req):
# def get_query_period(req):
# def get_query_group_by(req):
# def validate_query_name(name):
# def validate_query_dimensions(dimensions):
# def paginate(resource, uri, limit):
# def paginate_with_no_id(dictionary_list, uri, offset, limit):
# def _truncate_with_offset(resource, value_list, offset):
# def paginate_alarming(resource, uri, limit):
# def paginate_dimension_values(dimvals, uri, offset, limit):
# def _truncate_dimension_values(values, limit, offset):
# def paginate_measurements(measurements, uri, limit):
# def _get_old_query_params(parsed_uri):
# def _get_old_query_params_except_offset(new_query_params, parsed_uri):
# def paginate_statistics(statistics, uri, limit):
# def create_alarms_count_next_link(uri, offset, limit):
# def build_base_uri(parsed_uri):
# def get_link(uri, resource_id, rel='self'):
# def add_links_to_resource(resource, uri, rel='self'):
# def add_links_to_resource_list(resourcelist, uri):
# def raise_not_found_exception(resource_name, resource_id, tenant_id):
# def str_2_bool(s):


from unittest.mock import Mock
from monasca_api.tests import base
from monasca_api.v2.reference import helpers
    def test_comma_sep_dimensions(self):
        req = Mock()

        req.query_string = ("foo=bar&"
                            "dimensions=Dimension:Value,Dimension-2:Value-2")

        result = helpers.get_query_dimensions(req)

        self.assertEqual(
            result, {"Dimension": "Value", "Dimension-2": "Value-2"})

    def test_multiple_dimension_params(self):
        req = Mock()

        req.query_string = ("foo=bar&"
                            "dimensions=Dimension:Value&"
                            "dimensions=Dimension-2:Value-2")

        result = helpers.get_query_dimensions(req)

        self.assertEqual(
            result, {"Dimension": "Value", "Dimension-2": "Value-2"})

    def test_multiple_dimension_params_with_comma_sep_dimensions(self):
        req = Mock()

        req.query_string = ("foo=bar&"
                            "dimensions=Dimension-3:Value-3&"
                            "dimensions=Dimension:Value,Dimension-2:Value-2")


# Path: monasca_api/v2/reference/helpers.py
# LOG = log.getLogger(__name__)
# CONF = conf.CONF
# def from_json(req):
# def to_json(data):
# def validate_json_content_type(req):
# def validate_authorization(http_request, authorized_rules_list):
# def validate_payload_size(content_length):
# def get_x_tenant_or_tenant_id(http_request, delegate_authorized_rules_list):
# def get_query_param(req, param_name, required=False, default_val=None):
# def get_query_name(req, name_required=False):
# def get_query_dimensions(req, param_key='dimensions'):
# def get_query_starttime_timestamp(req, required=True):
# def get_query_endtime_timestamp(req, required=True):
# def validate_start_end_timestamps(start_timestamp, end_timestamp=None):
# def _convert_time_string(date_time_string):
# def get_query_statistics(req):
# def get_query_period(req):
# def get_query_group_by(req):
# def validate_query_name(name):
# def validate_query_dimensions(dimensions):
# def paginate(resource, uri, limit):
# def paginate_with_no_id(dictionary_list, uri, offset, limit):
# def _truncate_with_offset(resource, value_list, offset):
# def paginate_alarming(resource, uri, limit):
# def paginate_dimension_values(dimvals, uri, offset, limit):
# def _truncate_dimension_values(values, limit, offset):
# def paginate_measurements(measurements, uri, limit):
# def _get_old_query_params(parsed_uri):
# def _get_old_query_params_except_offset(new_query_params, parsed_uri):
# def paginate_statistics(statistics, uri, limit):
# def create_alarms_count_next_link(uri, offset, limit):
# def build_base_uri(parsed_uri):
# def get_link(uri, resource_id, rel='self'):
# def add_links_to_resource(resource, uri, rel='self'):
# def add_links_to_resource_list(resourcelist, uri):
# def raise_not_found_exception(resource_name, resource_id, tenant_id):
# def str_2_bool(s):


# Path: monasca_api/tests/test_query_helpers.py
from unittest.mock import Mock
from monasca_api.tests import base
from monasca_api.v2.reference import helpers

    def test_comma_sep_dimensions(self):
        req = Mock()

        req.query_string = ("foo=bar&"
                            "dimensions=Dimension:Value,Dimension-2:Value-2")

        result = helpers.get_query_dimensions(req)

        self.assertEqual(
            result, {"Dimension": "Value", "Dimension-2": "Value-2"})

    def test_multiple_dimension_params(self):
        req = Mock()

        req.query_string = ("foo=bar&"
                            "dimensions=Dimension:Value&"
                            "dimensions=Dimension-2:Value-2")

        result = helpers.get_query_dimensions(req)

        self.assertEqual(
            result, {"Dimension": "Value", "Dimension-2": "Value-2"})

    def test_multiple_dimension_params_with_comma_sep_dimensions(self):
        req = Mock()

        req.query_string = ("foo=bar&"
                            "dimensions=Dimension-3:Value-3&"
                            "dimensions=Dimension:Value,Dimension-2:Value-2")


        result = helpers.get_query_dimensions(req)