def _tx(): SearchEntry.insert( s, SearchClasses.EXACT, u'e', u'i', u'RESULT', u'type', value) for mutation in [casefold, spaced, punctuated]: self.assertThat( list(SearchEntry.search( s, SearchClasses.EXACT, u'e', u'i', mutation(value))), Annotate( 'Not found for {!r}({!r}) == {!r}'.format( mutation, value, mutation(value)), Equals([u'RESULT'])))
def _tx(): SearchEntry.insert(s, SearchClasses.PREFIX, u'e', u'i', u'RESULT', u'type', u'yo') self.assertThat(s.query(SearchEntry).count(), Equals(1)) self.assertThat([ list( SearchEntry.search(s, SearchClasses.PREFIX, u'e', u'i', u'')), list( SearchEntry.search(s, SearchClasses.PREFIX, u'e', u'i', u'. .')) ], AllMatch(Equals([])))
def _tx(): for x in xrange(50): SearchEntry.insert(s, SearchClasses.EXACT, u'e', u'i', u'RESULT', u'type{}'.format(x), u'yo') self.assertThat(s.query(SearchEntry).count(), Equals(50)) self.assertThat( list( SearchEntry.search(s, SearchClasses.EXACT, u'e', u'i', u'yo', limit=20)), HasLength(20))
def _tx(): SearchEntry.insert( s, SearchClasses.EXACT, environment, indexType, result, searchType, searchValue) self.assertThat( list(SearchEntry.search( s, SearchClasses.EXACT, environment, indexType, searchValue)), Equals([result])) self.assertThat( list(SearchEntry.search( s, SearchClasses.EXACT, environment, indexType, searchValue, searchType)), Equals([result])) SearchEntry.remove( s, SearchClasses.EXACT, environment, indexType, result, searchType) self.assertThat( list(SearchEntry.search( s, SearchClasses.EXACT, environment, indexType, searchValue)), Equals([])) self.assertThat( list(SearchEntry.search( s, SearchClasses.EXACT, environment, indexType, searchValue, searchType)), Equals([]))
def _tx(): SearchEntry.insert(s, SearchClasses.EXACT, environment, indexType, result, searchType, searchValue) self.assertThat( list( SearchEntry.search(s, SearchClasses.EXACT, environment, indexType, searchValue)), Equals([{ u'result': result, u'type': searchType }])) self.assertThat( list( SearchEntry.search(s, SearchClasses.EXACT, environment, indexType, searchValue, searchType)), Equals([{ u'result': result, u'type': searchType }])) SearchEntry.remove(s, SearchClasses.EXACT, environment, indexType, result, searchType) self.assertThat( list( SearchEntry.search(s, SearchClasses.EXACT, environment, indexType, searchValue)), Equals([])) self.assertThat( list( SearchEntry.search(s, SearchClasses.EXACT, environment, indexType, searchValue, searchType)), Equals([]))
def _tx(): SearchEntry.insert(s, SearchClasses.EXACT, u'e', u'i', u'RESULT', u'type', value) for mutation in [casefold, spaced, punctuated]: self.assertThat( list( SearchEntry.search(s, SearchClasses.EXACT, u'e', u'i', mutation(value))), Annotate( 'Not found for {!r}({!r}) == {!r}'.format( mutation, value, mutation(value)), Equals([{ u'result': u'RESULT', u'type': u'type' }])))
def render_GET(self, request): with LOG_SEARCH_GET(**self.params) as action: results = self.store.transact(lambda: list( SearchEntry.search(store=self.store, **self.params))) action.add_success_fields(results=results) request.setHeader('Content-Type', 'application/json') return json.dumps(results)
def render_GET(self, request): with LOG_SEARCH_GET(**self.params) as action: results = self.store.transact( lambda: list( SearchEntry.search(store=self.store, **self.params))) action.add_success_fields(results=results) request.setHeader('Content-Type', 'application/json') return json.dumps(results)
def test_prefixSearches(self, environment, indexType, searchValue, searchType, result): """ Test inserting, searching, and removing for the prefix search class. """ assume(SearchEntry._normalize(searchValue[:3]) != u'') s = Store() def _tx(): SearchEntry.insert(s, SearchClasses.PREFIX, environment, indexType, result, searchType, searchValue) self.assertThat( list( SearchEntry.search(s, SearchClasses.PREFIX, environment, indexType, searchValue[:3])), Equals([{ u'result': result, u'type': searchType }])) self.assertThat( list( SearchEntry.search(s, SearchClasses.PREFIX, environment, indexType, 'a' + searchValue)), Equals([])) self.assertThat( list( SearchEntry.search(s, SearchClasses.PREFIX, environment, indexType, searchValue)), Equals([{ u'result': result, u'type': searchType }])) self.assertThat( list( SearchEntry.search(s, SearchClasses.PREFIX, environment, indexType, searchValue, searchType)), Equals([{ u'result': result, u'type': searchType }])) SearchEntry.remove(s, SearchClasses.PREFIX, environment, indexType, result, searchType) self.assertThat( list( SearchEntry.search(s, SearchClasses.PREFIX, environment, indexType, searchValue)), Equals([])) self.assertThat( list( SearchEntry.search(s, SearchClasses.PREFIX, environment, indexType, searchValue, searchType)), Equals([])) s.transact(_tx)
def _tx(): SearchEntry.insert( s, SearchClasses.EXACT, u'e', u'i', u'RESULT', u'type', u'. /') self.assertThat(s.query(SearchEntry).count(), Equals(0)) SearchEntry.insert( s, SearchClasses.EXACT, u'e', u'i', u'RESULT', u'type', u'yo') self.assertThat(s.query(SearchEntry).count(), Equals(1)) SearchEntry.insert( s, SearchClasses.EXACT, u'e', u'i', u'RESULT', u'type', u'. /') self.assertThat(s.query(SearchEntry).count(), Equals(0))
def _tx(): SearchEntry.insert(s, SearchClasses.EXACT, u'e', u'i', u'RESULT', u'type', u'. /') self.assertThat(s.query(SearchEntry).count(), Equals(0)) SearchEntry.insert(s, SearchClasses.EXACT, u'e', u'i', u'RESULT', u'type', u'yo') self.assertThat(s.query(SearchEntry).count(), Equals(1)) SearchEntry.insert(s, SearchClasses.EXACT, u'e', u'i', u'RESULT', u'type', u'. /') self.assertThat(s.query(SearchEntry).count(), Equals(0))
def test_prefixSearches(self, environment, indexType, searchValue, searchType, result): """ Test inserting, searching, and removing for the prefix search class. """ assume(SearchEntry._normalize(searchValue) != u'') s = Store() def _tx(): SearchEntry.insert( s, SearchClasses.PREFIX, environment, indexType, result, searchType, searchValue) self.assertThat( list(SearchEntry.search( s, SearchClasses.PREFIX, environment, indexType, searchValue[:3])), Equals([result])) self.assertThat( list(SearchEntry.search( s, SearchClasses.PREFIX, environment, indexType, 'a' + searchValue)), Equals([])) self.assertThat( list(SearchEntry.search( s, SearchClasses.PREFIX, environment, indexType, searchValue)), Equals([result])) self.assertThat( list(SearchEntry.search( s, SearchClasses.PREFIX, environment, indexType, searchValue, searchType)), Equals([result])) SearchEntry.remove( s, SearchClasses.PREFIX, environment, indexType, result, searchType) self.assertThat( list(SearchEntry.search( s, SearchClasses.PREFIX, environment, indexType, searchValue)), Equals([])) self.assertThat( list(SearchEntry.search( s, SearchClasses.PREFIX, environment, indexType, searchValue, searchType)), Equals([])) s.transact(_tx)