Sha256: f8ddcc693516698fc8034b9425ee2954856a3b5fe2b7845eace637deb0c32089

Contents?: true

Size: 1.47 KB

Versions: 1

Compression:

Stored size: 1.47 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")
    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

1 entries across 1 versions & 1 rubygems

Version Path
dpickett-amazon_associate-0.6.1 test/amazon_associate/browse_node_lookup_test.rb