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)
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()
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()
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
def test_searches_fields_basic_matrix_with_facets_response_field_init(): from snovault.elasticsearch.searches.fields import BasicMatrixWithFacetsResponseField bmwf = BasicMatrixWithFacetsResponseField() assert isinstance(bmwf, BasicMatrixWithFacetsResponseField)