test/unit/peddler/test_client.rb in peddler-1.1.1 vs test/unit/peddler/test_client.rb in peddler-1.2.0

- old
+ new

@@ -1,28 +1,17 @@ require 'helper' -require 'excon' -require 'peddler/client' +require 'null_client' class TestPeddlerClient < MiniTest::Test - module Parser - def self.new(res, *) - res - end - end - def setup @body = 'foo' Excon.defaults[:mock] = true Excon.stub({}, body: @body, status: 200) - @klass = Class.new(Peddler::Client) - @klass.parser = Parser + @klass = Class.new(Null::Client) @client = @klass.new - @client.aws_access_key_id = 'key' - @client.aws_secret_access_key = 'secret' - @client.merchant_id = 'seller' - @client.primary_marketplace_id = 'ATVPDKIKX0DER' # US + @client.configure_with_mock_data! @client.operation('Foo') end def teardown Excon.stubs.clear @@ -51,10 +40,18 @@ def test_inherits_parents_params assert_equal Peddler::Client.params, @klass.params end + def test_inherits_parents_path + assert_equal @klass.path, Class.new(@klass).path + end + + def test_inherits_parents_parser + assert_equal @klass.parser, Class.new(@klass).parser + end + def test_params_include_seller_id assert @klass.params.key?("SellerId") end def test_params_include_auth_token @@ -172,16 +169,12 @@ @klass.on_error do |e| assert_equal 503, e.response.status end @client.run # no longer raises - klass = Class.new(Peddler::Client) - klass.parser = Parser + klass = Class.new(Null::Client) other_client = klass.new - other_client.aws_access_key_id = 'key' - other_client.aws_secret_access_key = 'secret' - other_client.merchant_id = 'seller' - other_client.primary_marketplace_id = 'ATVPDKIKX0DER' # US + other_client.configure_with_mock_data! other_client.operation('Foo') assert_raises(Excon::Errors::ServiceUnavailable) do other_client.run end