Sha256: 6faf5a88911b5fcbccb14b2cb400281e3de59d14c29f99fe1eff87319bcbc86d

Contents?: true

Size: 1.5 KB

Versions: 6

Compression:

Stored size: 1.5 KB

Contents

require File.dirname(__FILE__) + "/../test_helper"

class AmazonAssociate::BrowseNodeLookupTest < Test::Unit::TestCase
  
  ## Test browse_node_lookup
  def test_browse_node_lookup
    resp = AmazonAssociate::Request.browse_node_lookup("5", :response_group => "TopSellers")
    assert resp.is_valid_request?
    browse_node_tags = resp.doc.get_elements_by_tag_name("browsenodeid")
    browse_node_tags.each { |node| assert_equal("5", node.inner_text) }
    assert_equal "TopSellers", resp.doc.get_elements_by_tag_name("responsegroup").inner_text
  end
  
  def test_browse_node_lookup_with_browse_node_info_response
    resp = AmazonAssociate::Request.browse_node_lookup("5", :response_group => "BrowseNodeInfo")
    assert resp.is_valid_request?
    assert_equal "BrowseNodeInfo", resp.doc.get_elements_by_tag_name("responsegroup").inner_text
  end
  
  def test_browse_node_lookup_with_new_releases_response
    resp = AmazonAssociate::Request.browse_node_lookup("5", :response_group => "NewReleases")
    assert resp.is_valid_request?
    assert_equal "NewReleases", resp.doc.get_elements_by_tag_name("responsegroup").inner_text
  end
  
  def test_browse_node_lookup_with_invalid_request
    resp = AmazonAssociate::Request.browse_node_lookup(nil)
    assert resp.has_error?
    assert resp.error
  end

  def test_browse_node_lookup_with_no_result
    resp = AmazonAssociate::Request.browse_node_lookup("abc")
    
    assert resp.is_valid_request?
    assert_match(/abc is not a valid value for BrowseNodeId/, resp.error)
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
dpickett-amazon_associate-0.6.2 test/amazon_associate/browse_node_lookup_test.rb
dpickett-amazon_associate-0.6.3 test/amazon_associate/browse_node_lookup_test.rb
dpickett-amazon_associate-0.6.4 test/amazon_associate/browse_node_lookup_test.rb
dpickett-amazon_associate-0.6.5 test/amazon_associate/browse_node_lookup_test.rb
dpickett-amazon_associate-0.7.0 test/amazon_associate/browse_node_lookup_test.rb
amazon_associate-0.7.0 test/amazon_associate/browse_node_lookup_test.rb