mirror of
https://github.com/apache/lucene.git
synced 2025-02-21 17:46:28 +00:00
getting a start on some Flare plugin unit tests
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@529547 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
db21821167
commit
bcf88974a9
@ -24,7 +24,7 @@ class Flare::Context
|
|||||||
clear
|
clear
|
||||||
@facet_queries = {} # name => {:queries => [], :filters => []}
|
@facet_queries = {} # name => {:queries => [], :filters => []}
|
||||||
|
|
||||||
@index_info = @connection.send(Solr::Request::IndexInfo.new)
|
@index_info = index_info
|
||||||
|
|
||||||
excluded = @solr_config[:facets_exclude] ? @solr_config[:facets_exclude].collect {|e| e.to_s} : []
|
excluded = @solr_config[:facets_exclude] ? @solr_config[:facets_exclude].collect {|e| e.to_s} : []
|
||||||
@facet_fields = @index_info.field_names.find_all {|v| v =~ /_facet$/} - excluded # TODO: is facets_excluded working? where are the tests?! :)
|
@facet_fields = @index_info.field_names.find_all {|v| v =~ /_facet$/} - excluded # TODO: is facets_excluded working? where are the tests?! :)
|
||||||
@ -42,7 +42,7 @@ class Flare::Context
|
|||||||
@page = 1
|
@page = 1
|
||||||
|
|
||||||
# this is cleared for development purposes - allowing flare to stay running but different Solr datasets swapping
|
# this is cleared for development purposes - allowing flare to stay running but different Solr datasets swapping
|
||||||
@index_info = @connection.send(Solr::Request::IndexInfo.new)
|
@index_info = index_info
|
||||||
excluded = @solr_config[:facets_exclude] ? @solr_config[:facets_exclude].collect {|e| e.to_s} : []
|
excluded = @solr_config[:facets_exclude] ? @solr_config[:facets_exclude].collect {|e| e.to_s} : []
|
||||||
@facet_fields = @index_info.field_names.find_all {|v| v =~ /_facet$/} - excluded
|
@facet_fields = @index_info.field_names.find_all {|v| v =~ /_facet$/} - excluded
|
||||||
@text_fields = @index_info.field_names.find_all {|v| v =~ /_text$/}
|
@text_fields = @index_info.field_names.find_all {|v| v =~ /_text$/}
|
||||||
@ -143,4 +143,8 @@ class Flare::Context
|
|||||||
"#{filter[:negative] ? '-' : ''}#{filter[:field]}:#{value}"
|
"#{filter[:negative] ? '-' : ''}#{filter[:field]}:#{value}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def index_info
|
||||||
|
@connection.send(Solr::Request::IndexInfo.new)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
71
client/ruby/flare/vendor/plugins/flare/test/flare_context_test.rb
vendored
Executable file
71
client/ruby/flare/vendor/plugins/flare/test/flare_context_test.rb
vendored
Executable file
@ -0,0 +1,71 @@
|
|||||||
|
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
# (the "License"); you may not use this file except in compliance with
|
||||||
|
# the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
require 'test/unit'
|
||||||
|
require 'flare'
|
||||||
|
|
||||||
|
class Flare::Context
|
||||||
|
def index_info
|
||||||
|
Solr::Response::IndexInfo.new(<<RUBY_CODE
|
||||||
|
{
|
||||||
|
'responseHeader'=>{
|
||||||
|
'status'=>0,
|
||||||
|
'QTime'=>7},
|
||||||
|
'fields'=>{
|
||||||
|
'body_zh_text'=>{'type'=>'text_zh'},
|
||||||
|
'type_zh_facet'=>{'type'=>'string'},
|
||||||
|
'subject_era_facet'=>{'type'=>'string'},
|
||||||
|
'call_number_display'=>{'type'=>'text'},
|
||||||
|
'id'=>{'type'=>'string'},
|
||||||
|
'title_text'=>{'type'=>'text'},
|
||||||
|
'isbn_text'=>{'type'=>'text'},
|
||||||
|
'source_facet'=>{'type'=>'string'},
|
||||||
|
'subject_geographic_facet'=>{'type'=>'string'},
|
||||||
|
'author_text'=>{'type'=>'text'},
|
||||||
|
'marc_text'=>{'type'=>'text'},
|
||||||
|
'body_en_text'=>{'type'=>'text'},
|
||||||
|
'author_zh_facet'=>{'type'=>'string'},
|
||||||
|
'title_en_text'=>{'type'=>'text'},
|
||||||
|
'subject_topic_facet'=>{'type'=>'string'},
|
||||||
|
'library_facet'=>{'type'=>'string'},
|
||||||
|
'subject_genre_facet'=>{'type'=>'string'},
|
||||||
|
'external_url_display'=>{'type'=>'text'},
|
||||||
|
'format_facet'=>{'type'=>'string'},
|
||||||
|
'type_en_facet'=>{'type'=>'string'},
|
||||||
|
'author_en_facet'=>{'type'=>'string'},
|
||||||
|
'text'=>{'type'=>'text'},
|
||||||
|
'call_number_facet'=>{'type'=>'string'},
|
||||||
|
'year_facet'=>{'type'=>'string'},
|
||||||
|
'location_facet'=>{'type'=>'string'},
|
||||||
|
'title_zh_text'=>{'type'=>'text_zh'}},
|
||||||
|
'index'=>{
|
||||||
|
'maxDoc'=>1337165,
|
||||||
|
'numDocs'=>1337159,
|
||||||
|
'version'=>'1174965134952'}}
|
||||||
|
RUBY_CODE
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class FlareContextTest < Test::Unit::TestCase
|
||||||
|
def setup
|
||||||
|
@flare_context = Flare::Context.new({:solr_url => 'http://localhost:8983/solr'})
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_clear
|
||||||
|
@flare_context.page = 5
|
||||||
|
@flare_context.clear
|
||||||
|
assert_equal @flare_context.page, 1
|
||||||
|
end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user