def project_info():
    return aggregate(
        'projects',
        queries.project_info,
        app,
        post_processing=[server_side.post_processing.date_to_string('_created')]
    )
def sample():
    return aggregate(
        'samples',
        queries.sample,
        app,
        post_processing=[server_side.post_processing.cast_to_sets('run_ids')]
    )
def run_info():
    return aggregate(
        'runs',
        queries.sequencing_run_information,
        app,
        post_processing=[server_side.post_processing.cast_to_sets('project_ids', 'review_statuses', 'useable_statuses')]
    )
def test_aggregate():
    patched_resolve_pipeline = patch("rest_api.aggregation.database_side.queries.resolve_pipeline")
    patched_request = patch("rest_api.aggregation.database_side.request", new=FakeRequest({}))
    patched_jsonify = patch("rest_api.aggregation.database_side.jsonify", new=dict)
    with patched_resolve_pipeline, patched_request, patched_jsonify:
        obs = database_side.aggregate(
            "test_endpoint",
            [{"a": "test", "aggregataion": "pipeline"}],
            Mock(
                logger=Mock(),
                config={
                    "QUERY_PAGE": "page",
                    "QUERY_MAX_RESULTS": "max_results",
                    "META": "_meta",
                    "LINKS": "_links",
                    "ITEMS": "data",
                },
            ),
        )
    exp = {"_meta": {"total": 2}, "data": fake_data}
    assert obs == exp
def demultiplexing():
    return aggregate(
        'run_elements',
        queries.demultiplexing,
        app
    )
def aggregate_by_lane():
    return aggregate('run_elements', queries.run_elements_group_by_lane, app)