# Path: dax/utilities.py
# def decode_url_json_string(json_string):
# def parse_json_pairs(pairs):
# def groupby_to_dict(source, group_pred):
# def groupby_groupby_to_dict(source, outer_pred, inner_pred):
# def find_with_pred(items, pred):
# def strip_leading_and_trailing_spaces(list_arg):
# def extract_exp(expression, full_regex=False):
# def clean_directory(directory):
# def check_image_format(fpath):
# def read_yaml(yaml_file):
# def send_email(smtp_from, smtp_host, smtp_pass, to_addr, subject, content):
# def send_email_netrc(smtp_host, to_addr, subject, content):


from unittest import TestCase
from dax import utilities
    def test_groupby_to_dict(self):
        source = [{'a': 1, 'b': 1}, {'a': 2, 'b': 2}, {'a': 3, 'b': 1}, {'a': 4, 'b': 2}]

        actual = utilities.groupby_to_dict(source, lambda x: x['b'])
        expected = {
            1: [{'a': 1, 'b': 1}, {'a': 3, 'b': 1}],
            2: [{'a': 2, 'b': 2}, {'a': 4, 'b': 2}]
        }

        self.assertDictEqual(actual, expected)

    def test_groupby_to_dict_2(self):
        source = [{'a': 1, 'b': 1}, {'a': 2, 'b': 2}, {'a': 3, 'b': 2}, {'a': 4, 'b': 1}]

        actual = utilities.groupby_to_dict(source, lambda x: x['b'])
        expected = {
            1: [{'a': 1, 'b': 1}, {'a': 4, 'b': 1}],
            2: [{'a': 2, 'b': 2}, {'a': 3, 'b': 2}]
        }

        self.assertDictEqual(actual, expected)

    def test_groupby_groupby_to_dict(self):
        source = [
            {'a': 1, 'b': 10, 'c': 100},
            {'a': 1, 'b': 11, 'c': 101},
            {'a': 1, 'b': 11, 'c': 102},
            {'a': 2, 'b': 12, 'c': 103},
            {'a': 1, 'b': 10, 'c': 104}
        ]

# Path: dax/utilities.py
# def decode_url_json_string(json_string):
# def parse_json_pairs(pairs):
# def groupby_to_dict(source, group_pred):
# def groupby_groupby_to_dict(source, outer_pred, inner_pred):
# def find_with_pred(items, pred):
# def strip_leading_and_trailing_spaces(list_arg):
# def extract_exp(expression, full_regex=False):
# def clean_directory(directory):
# def check_image_format(fpath):
# def read_yaml(yaml_file):
# def send_email(smtp_from, smtp_host, smtp_pass, to_addr, subject, content):
# def send_email_netrc(smtp_host, to_addr, subject, content):


# Path: dax/tests/unit_test_utilities.py
from unittest import TestCase
from dax import utilities

    def test_groupby_to_dict(self):
        source = [{'a': 1, 'b': 1}, {'a': 2, 'b': 2}, {'a': 3, 'b': 1}, {'a': 4, 'b': 2}]

        actual = utilities.groupby_to_dict(source, lambda x: x['b'])
        expected = {
            1: [{'a': 1, 'b': 1}, {'a': 3, 'b': 1}],
            2: [{'a': 2, 'b': 2}, {'a': 4, 'b': 2}]
        }

        self.assertDictEqual(actual, expected)

    def test_groupby_to_dict_2(self):
        source = [{'a': 1, 'b': 1}, {'a': 2, 'b': 2}, {'a': 3, 'b': 2}, {'a': 4, 'b': 1}]

        actual = utilities.groupby_to_dict(source, lambda x: x['b'])
        expected = {
            1: [{'a': 1, 'b': 1}, {'a': 4, 'b': 1}],
            2: [{'a': 2, 'b': 2}, {'a': 3, 'b': 2}]
        }

        self.assertDictEqual(actual, expected)

    def test_groupby_groupby_to_dict(self):
        source = [
            {'a': 1, 'b': 10, 'c': 100},
            {'a': 1, 'b': 11, 'c': 101},
            {'a': 1, 'b': 11, 'c': 102},
            {'a': 2, 'b': 12, 'c': 103},
            {'a': 1, 'b': 10, 'c': 104}
        ]

        actual = utilities.groupby_groupby_to_dict(source, lambda x: x['a'], lambda y: y['b'])