예제 #1
0
def test_searches_fields_basic_matrix_with_facets_response_field_build_query(
        dummy_parent):
    from snovault.elasticsearch.searches.fields import BasicMatrixWithFacetsResponseField
    from snovault.elasticsearch.searches.queries import BasicMatrixQueryFactoryWithFacets
    from elasticsearch_dsl import Search
    dummy_parent._meta['params_parser']._request.environ['QUERY_STRING'] = (
        'type=TestingSearchSchema&status=released')
    bmwf = BasicMatrixWithFacetsResponseField()
    bmwf.parent = dummy_parent
    bmwf._build_query()
    assert isinstance(bmwf.query, Search)
    assert isinstance(bmwf.query_builder, BasicMatrixQueryFactoryWithFacets)
예제 #2
0
def summary(context, request):
    fr = FieldedResponse(
        _meta={
            'params_parser': ParamsParser(request)
        },
        response_fields=[
            TitleResponseField(
                title=SUMMARY_TITLE
            ),
            TypeResponseField(
                at_type=[SUMMARY_TITLE]
            ),
            IDResponseField(),
            SearchBaseResponseField(),
            ContextResponseField(),
            BasicMatrixWithFacetsResponseField(
                default_item_types=DEFAULT_ITEM_TYPES,
                matrix_definition_name=SUMMARY_MATRIX
            ),
            NotificationResponseField(),
            FiltersResponseField(),
            TypeOnlyClearFiltersResponseField(),
            DebugQueryResponseField()
        ]
    )
    return fr.render()
예제 #3
0
def mouse_development(context, request):
    fr = FieldedResponse(
        _meta={
            'params_parser': ParamsParser(request)
        },
        response_fields=[
            TitleResponseField(
                title='Mouse Development Matrix'
            ),
            TypeResponseField(
                at_type=['MouseDevelopmentMatrix']
            ),
            IDResponseField(),
            SearchBaseResponseField(),
            ContextResponseField(),
            BasicMatrixWithFacetsResponseField(
                default_item_types=DEFAULT_ITEM_TYPES,
                matrix_definition_name='mouse_development'
            ),
            NotificationResponseField(),
            FiltersResponseField(),
            TypeOnlyClearFiltersResponseField(),
            DebugQueryResponseField()
        ]
    )
    return fr.render()
예제 #4
0
def test_searches_fields_basic_matrix_with_facets_response_field_execute_query(
        dummy_parent, mocker):
    from snovault.elasticsearch.searches.fields import BasicMatrixWithFacetsResponseField
    from elasticsearch_dsl import Search
    mocker.patch.object(Search, 'execute')
    dummy_parent._meta['params_parser']._request.environ['QUERY_STRING'] = (
        'type=TestingSearchSchema&status=released')
    bmwf = BasicMatrixWithFacetsResponseField()
    bmwf.parent = dummy_parent
    bmwf._build_query()
    bmwf._execute_query()
    assert Search.execute.call_count == 1
예제 #5
0
def test_searches_fields_basic_matrix_with_facets_response_field_init():
    from snovault.elasticsearch.searches.fields import BasicMatrixWithFacetsResponseField
    bmwf = BasicMatrixWithFacetsResponseField()
    assert isinstance(bmwf, BasicMatrixWithFacetsResponseField)