# Path: performanceplatform/collector/ga/plugins/load_plugin.py
# def load_plugin(plugin_name):
# 
#     expr = compile(plugin_name, "performanceplatform.collector plugin", "eval")
# 
#     return eval(expr, __builtin__.__dict__,
#                 performanceplatform.collector.ga.plugins.__dict__)
# 
# Path: performanceplatform/collector/ga/plugins/aggregate.py
# class AggregateKey(object):
# 
#     """
#     Given a set of documents, find all records with equal "key" where the "key"
#     is all values which are not being aggregated over.
# 
#     For example:
# 
#         doc1 = {"foo": "bar", "count": 2}
#         doc2 = {"foo": "bar", "count": 2}
# 
#         plugin = AggregateKey(aggregate_count("count"))
# 
#         plugin([doc1, doc2]) => {"foo": "bar", "count": 4}
# 
#     Aggregate rates are also supported through
#     `aggregate_rate(rate_key, count_key)`.
#     """
# 
#     def __init__(self, *aggregations):
#         self.aggregations = aggregations
# 
#     def __call__(self, documents):
#         first = documents[0]
# 
#         aggregate_keys = [k for k, _ in self.aggregations]
#         groupkeys = set(first) - set(aggregate_keys)
# 
#         def key(doc):
#             return tuple(doc[key] for key in groupkeys)
# 
#         return [make_aggregate(grouped, self.aggregations)
#                 for grouped in group(documents, key)]
# 
# Path: performanceplatform/collector/ga/plugins/department.py
# class ComputeDepartmentKey(object):
# 
#     """
#     Adds a 'department' key to a dictionary by looking up the department from
#     the specified, key_name. It takes the first department code of form
#     <[code]> from document[key_name].
#     """
# 
#     def __init__(self, key_name):
#         self.key_name = key_name
# 
#     def __call__(self, documents):
#         def compute_department(department):
#             assert self.key_name in document, (
#                 'key "{}" not found "{}"'.format(self.key_name, document))
#             department_codes = document[self.key_name]
#             department_code = take_first_department_code(department_codes)
#             document["department"] = DEPARTMENT_MAPPING.get(
#                 department_code, department_code)
#             return document
# 
#         return [compute_department(document) for document in documents]


from performanceplatform.collector.ga.plugins.load_plugin \
    import load_plugin
from performanceplatform.collector.ga.plugins \
    import AggregateKey, ComputeDepartmentKey
    from nose.tools import assert_equal
    from nose.tools import assert_is_instance
    from nose.tools import assert_is_instance



def test_load_plugin_trivial():

    assert_equal(1, load_plugin("1"))


def test_load_plugin_compute_department_key():


# Path: performanceplatform/collector/ga/plugins/load_plugin.py
# def load_plugin(plugin_name):
# 
#     expr = compile(plugin_name, "performanceplatform.collector plugin", "eval")
# 
#     return eval(expr, __builtin__.__dict__,
#                 performanceplatform.collector.ga.plugins.__dict__)
# 
# Path: performanceplatform/collector/ga/plugins/aggregate.py
# class AggregateKey(object):
# 
#     """
#     Given a set of documents, find all records with equal "key" where the "key"
#     is all values which are not being aggregated over.
# 
#     For example:
# 
#         doc1 = {"foo": "bar", "count": 2}
#         doc2 = {"foo": "bar", "count": 2}
# 
#         plugin = AggregateKey(aggregate_count("count"))
# 
#         plugin([doc1, doc2]) => {"foo": "bar", "count": 4}
# 
#     Aggregate rates are also supported through
#     `aggregate_rate(rate_key, count_key)`.
#     """
# 
#     def __init__(self, *aggregations):
#         self.aggregations = aggregations
# 
#     def __call__(self, documents):
#         first = documents[0]
# 
#         aggregate_keys = [k for k, _ in self.aggregations]
#         groupkeys = set(first) - set(aggregate_keys)
# 
#         def key(doc):
#             return tuple(doc[key] for key in groupkeys)
# 
#         return [make_aggregate(grouped, self.aggregations)
#                 for grouped in group(documents, key)]
# 
# Path: performanceplatform/collector/ga/plugins/department.py
# class ComputeDepartmentKey(object):
# 
#     """
#     Adds a 'department' key to a dictionary by looking up the department from
#     the specified, key_name. It takes the first department code of form
#     <[code]> from document[key_name].
#     """
# 
#     def __init__(self, key_name):
#         self.key_name = key_name
# 
#     def __call__(self, documents):
#         def compute_department(department):
#             assert self.key_name in document, (
#                 'key "{}" not found "{}"'.format(self.key_name, document))
#             department_codes = document[self.key_name]
#             department_code = take_first_department_code(department_codes)
#             document["department"] = DEPARTMENT_MAPPING.get(
#                 department_code, department_code)
#             return document
# 
#         return [compute_department(document) for document in documents]


# Path: tests/performanceplatform/collector/ga/plugins/test_load_plugin.py
from performanceplatform.collector.ga.plugins.load_plugin \
    import load_plugin
from performanceplatform.collector.ga.plugins \
    import AggregateKey, ComputeDepartmentKey
    from nose.tools import assert_equal
    from nose.tools import assert_is_instance
    from nose.tools import assert_is_instance




def test_load_plugin_trivial():

    assert_equal(1, load_plugin("1"))


def test_load_plugin_compute_department_key():


    plugin = load_plugin('ComputeDepartmentKey("customVarValue9")')