def testSearchModeRegistry(self): def testSearchHandler(query, types, user, level, limit, offset): return {'query': query, 'types': types} search.addSearchMode('testSearch', testSearchHandler) # Use the new search mode. resp = self.request(path='/resource/search', params={ 'q': 'Test', 'mode': 'testSearch', 'types': json.dumps(["collection"]) }) self.assertStatusOk(resp) self.assertDictEqual(resp.json, { 'query': 'Test', 'types': ["collection"] }) search.removeSearchMode('testSearch') # Use the deleted search mode. resp = self.request(path='/resource/search', params={ 'q': 'Test', 'mode': 'testSearch', 'types': json.dumps(["collection"]) }) self.assertStatus(resp, 400)
def testSearchModeRegistry(self): def testSearchHandler(query, types, user, level, limit, offset): return { 'query': query, 'types': types } search.addSearchMode('testSearch', testSearchHandler) # Use the new search mode. resp = self.request(path='/resource/search', params={ 'q': 'Test', 'mode': 'testSearch', 'types': json.dumps(["collection"]) }) self.assertStatusOk(resp) self.assertDictEqual(resp.json, { 'query': 'Test', 'types': ["collection"] }) search.removeSearchMode('testSearch') # Use the deleted search mode. resp = self.request(path='/resource/search', params={ 'q': 'Test', 'mode': 'testSearch', 'types': json.dumps(["collection"]) }) self.assertStatus(resp, 400)
def load(info): Item().exposeFields(level=AccessType.READ, fields={'dicom'}) events.bind('data.process', 'dicom_viewer', _uploadHandler) # Add the DICOM search mode only once search.addSearchMode('dicom', dicomSubstringSearchHandler) dicomItem = DicomItem() info['apiRoot'].item.route('POST', (':id', 'parseDicom'), dicomItem.makeDicomItem)
def load(self, info): Item().exposeFields(level=AccessType.READ, fields={'dicom'}) events.bind('data.process', 'dicom_viewer', _uploadHandler) # Add the DICOM search mode only once search.addSearchMode('dicom', dicomSubstringSearchHandler) dicomItem = DicomItem() info['apiRoot'].item.route( 'POST', (':id', 'parseDicom'), dicomItem.makeDicomItem)
def load(self, info): info['apiRoot'].resource.route('GET', ('tags', ), getItemTags) Item().ensureIndex(([('meta.girder_item_tags', 1)], { 'collation': { 'locale': 'en_US', 'strength': 1 } })) # Pytest reloads the plugin for every test. # addSearchMode will break if called twice, so check if it's already been loaded. if search.getSearchModeHandler('item_tags') is None: search.addSearchMode('item_tags', search_handler)
def load(self, info): search.addSearchMode('dandi', dandi_search_handler)