Sha256: d00780bff6b22e5816b2545c3527645e6a0f7a70666dd9ba617f48ebe21c6cb6

Contents?: true

Size: 1.99 KB

Versions: 12

Compression:

Stored size: 1.99 KB

Contents

require 'helper' 

class TestSearchClient < Test::Unit::TestCase
  should "get the range request result" do
    range_request = RangeRequest.new
    search_request = SearchRequest.new
    search_request.category = 'VAUT'
    search_request.annotations = {:Make => "porsche"}
    range_request.search_request = search_request
    range_request.fields = ['price', 'year']
    client = SearchClient.new
    range_response = client.range(range_request)
    assert_equal RangeResponse, range_response.class
    assert_equal range_request.fields, range_response.ranges.collect{|r| r['field']}
  end

  should "get the search request result" do
    search_request = SearchRequest.new
    search_request.category = 'VAUT'
    search_request.rpp = 2
    search_request.annotations = {:Make => "porsche"}
    client = SearchClient.new
    search_response = client.search(search_request)
    assert_equal SearchResponse, search_response.class
    assert_equal Array, search_response.results.class
    assert_equal Hash, search_response.results.first.class
  end

  should "get the count request result" do
    search_request = SearchRequest.new
    search_request.category = 'VAUT'
    search_request.annotations = {:Make => "porsche"}
    client = SearchClient.new
    count_response = client.count(search_request)
    assert_equal CountResponse, count_response.class
    assert_not_equal nil , count_response.count

  end

  should "get the summary result" do
    search_request = SearchRequest.new
    search_request.category = 'VAUT'
    search_request.annotations = {:Make => "porsche"}
    client = SearchClient.new
    summary_response = client.summary(search_request)
    assert_equal SummaryResponse, summary_response.class
  end

  should "get the best match result" do
    search_keywords = "iPad Apple iPhone"
    client = SearchClient.new
    best_match_response = client.best_match(CGI.escape search_keywords)
    assert_equal BestMatchResponse, best_match_response.class
    assert_equal 'SELE', best_match_response.category
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
threetaps-client-1.0.14 test/client/test_search_client.rb
threetaps-client-1.0.13 test/client/test_search_client.rb
threetaps-client-1.0.12 test/client/test_search_client.rb
threetaps-client-1.0.11 test/client/test_search_client.rb
threetaps-client-1.0.10 test/client/test_search_client.rb
threetaps-client-1.0.9 test/client/test_search_client.rb
threetaps-client-1.0.8 test/client/test_search_client.rb
threetaps-client-1.0.7 test/client/test_search_client.rb
threetaps-client-1.0.6 test/client/test_search_client.rb
threetaps-client-1.0.5 test/client/test_search_client.rb
threetaps-client-1.0.4 test/client/test_search_client.rb
threetaps-client-1.0.3 test/client/test_search_client.rb