Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for child resources. #1013

Merged
merged 1 commit into from
Oct 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 149 additions & 0 deletions test/stripe/generated_examples_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,31 @@ class CodegennedExampleTest < Test::Unit::TestCase
assert_requested :get, "#{Stripe.api_base}/v1/balance_transactions/txn_xxxxxxxxxxxxx?"
end
end
context "Capability.list" do
should "support requests with args: parent_id" do
Stripe::Account.list_capabilities("acct_xxxxxxxxxxxxx")
assert_requested :get, "#{Stripe.api_base}/v1/accounts/acct_xxxxxxxxxxxxx/capabilities?"
end
end
context "Capability.retrieve" do
should "support requests with args: parent_id, id" do
Stripe::Account.retrieve_capability(
"acct_xxxxxxxxxxxxx",
"card_payments"
)
assert_requested :get, "#{Stripe.api_base}/v1/accounts/acct_xxxxxxxxxxxxx/capabilities/card_payments?"
end
end
context "Capability.update" do
should "support requests with args: requested, parent_id, id" do
Stripe::Account.update_capability(
"acct_xxxxxxxxxxxxx",
"card_payments",
{ requested: true }
)
assert_requested :post, "#{Stripe.api_base}/v1/accounts/acct_xxxxxxxxxxxxx/capabilities/card_payments"
end
end
context "Card.create" do
should "support requests with args: cardholder, currency, type" do
Stripe::Issuing::Card.create(
Expand Down Expand Up @@ -414,6 +439,34 @@ class CodegennedExampleTest < Test::Unit::TestCase
assert_requested :post, "#{Stripe.api_base}/v1/customers/cus_xxxxxxxxxxxxx"
end
end
context "CustomerBalanceTransaction.list" do
should "support requests with args: limit, parent_id" do
Stripe::Customer.list_balance_transactions(
"cus_xxxxxxxxxxxxx",
{ limit: 3 }
)
assert_requested :get, "#{Stripe.api_base}/v1/customers/cus_xxxxxxxxxxxxx/balance_transactions?limit=3"
end
end
context "CustomerBalanceTransaction.retrieve" do
should "support requests with args: parent_id, id" do
Stripe::Customer.retrieve_balance_transaction(
"cus_xxxxxxxxxxxxx",
"cbtxn_xxxxxxxxxxxxx"
)
assert_requested :get, "#{Stripe.api_base}/v1/customers/cus_xxxxxxxxxxxxx/balance_transactions/cbtxn_xxxxxxxxxxxxx?"
end
end
context "CustomerBalanceTransaction.update" do
should "support requests with args: metadata, parent_id, id" do
Stripe::Customer.update_balance_transaction(
"cus_xxxxxxxxxxxxx",
"cbtxn_xxxxxxxxxxxxx",
{ metadata: { order_id: "6735" } }
)
assert_requested :post, "#{Stripe.api_base}/v1/customers/cus_xxxxxxxxxxxxx/balance_transactions/cbtxn_xxxxxxxxxxxxx"
end
end
context "Dispute.close" do
should "support requests with args: id" do
Stripe::Dispute.close("dp_xxxxxxxxxxxxx")
Expand Down Expand Up @@ -508,6 +561,31 @@ class CodegennedExampleTest < Test::Unit::TestCase
assert_requested :get, "#{Stripe.api_base}/v1/events/evt_xxxxxxxxxxxxx?"
end
end
context "FeeRefund.list" do
should "support requests with args: limit, parent_id" do
Stripe::ApplicationFee.list_refunds("fee_xxxxxxxxxxxxx", { limit: 3 })
assert_requested :get, "#{Stripe.api_base}/v1/application_fees/fee_xxxxxxxxxxxxx/refunds?limit=3"
end
end
context "FeeRefund.retrieve" do
should "support requests with args: parent_id, id" do
Stripe::ApplicationFee.retrieve_refund(
"fee_xxxxxxxxxxxxx",
"fr_xxxxxxxxxxxxx"
)
assert_requested :get, "#{Stripe.api_base}/v1/application_fees/fee_xxxxxxxxxxxxx/refunds/fr_xxxxxxxxxxxxx?"
end
end
context "FeeRefund.update" do
should "support requests with args: metadata, parent_id, id" do
Stripe::ApplicationFee.update_refund(
"fee_xxxxxxxxxxxxx",
"fr_xxxxxxxxxxxxx",
{ metadata: { order_id: "6735" } }
)
assert_requested :post, "#{Stripe.api_base}/v1/application_fees/fee_xxxxxxxxxxxxx/refunds/fr_xxxxxxxxxxxxx"
end
end
context "File.list" do
should "support requests with args: limit" do
Stripe::File.list(limit: 3)
Expand Down Expand Up @@ -890,6 +968,31 @@ class CodegennedExampleTest < Test::Unit::TestCase
assert_requested :post, "#{Stripe.api_base}/v1/payouts/po_xxxxxxxxxxxxx"
end
end
context "Person.list" do
should "support requests with args: limit, parent_id" do
Stripe::Account.list_persons("acct_xxxxxxxxxxxxx", { limit: 3 })
assert_requested :get, "#{Stripe.api_base}/v1/accounts/acct_xxxxxxxxxxxxx/persons?limit=3"
end
end
context "Person.retrieve" do
should "support requests with args: parent_id, id" do
Stripe::Account.retrieve_person(
"acct_xxxxxxxxxxxxx",
"person_xxxxxxxxxxxxx"
)
assert_requested :get, "#{Stripe.api_base}/v1/accounts/acct_xxxxxxxxxxxxx/persons/person_xxxxxxxxxxxxx?"
end
end
context "Person.update" do
should "support requests with args: metadata, parent_id, id" do
Stripe::Account.update_person(
"acct_xxxxxxxxxxxxx",
"person_xxxxxxxxxxxxx",
{ metadata: { order_id: "6735" } }
)
assert_requested :post, "#{Stripe.api_base}/v1/accounts/acct_xxxxxxxxxxxxx/persons/person_xxxxxxxxxxxxx"
end
end
context "Plan.create" do
should "support requests with args: amount, currency, interval, product" do
Stripe::Plan.create(
Expand Down Expand Up @@ -1393,6 +1496,27 @@ class CodegennedExampleTest < Test::Unit::TestCase
assert_requested :post, "#{Stripe.api_base}/v1/subscription_schedules/sub_sched_xxxxxxxxxxxxx"
end
end
context "TaxId.delete" do
should "support requests with args: parent_id, id" do
Stripe::Customer.delete_tax_id("cus_xxxxxxxxxxxxx", "txi_xxxxxxxxxxxxx")
assert_requested :delete, "#{Stripe.api_base}/v1/customers/cus_xxxxxxxxxxxxx/tax_ids/txi_xxxxxxxxxxxxx?"
end
end
context "TaxId.list" do
should "support requests with args: limit, parent_id" do
Stripe::Customer.list_tax_ids("cus_xxxxxxxxxxxxx", { limit: 3 })
assert_requested :get, "#{Stripe.api_base}/v1/customers/cus_xxxxxxxxxxxxx/tax_ids?limit=3"
end
end
context "TaxId.retrieve" do
should "support requests with args: id, parent_id" do
Stripe::Customer.retrieve_tax_id(
"cus_xxxxxxxxxxxxx",
"txi_xxxxxxxxxxxxx"
)
assert_requested :get, "#{Stripe.api_base}/v1/customers/cus_xxxxxxxxxxxxx/tax_ids/txi_xxxxxxxxxxxxx?"
end
end
context "TaxRate.create" do
should "support requests with args: display_name, description, jurisdiction, percentage, inclusive" do
Stripe::TaxRate.create(
Expand Down Expand Up @@ -1570,6 +1694,31 @@ class CodegennedExampleTest < Test::Unit::TestCase
assert_requested :post, "#{Stripe.api_base}/v1/transfers/tr_xxxxxxxxxxxxx"
end
end
context "TransferReversal.list" do
should "support requests with args: limit, parent_id" do
Stripe::Transfer.list_reversals("tr_xxxxxxxxxxxxx", { limit: 3 })
assert_requested :get, "#{Stripe.api_base}/v1/transfers/tr_xxxxxxxxxxxxx/reversals?limit=3"
end
end
context "TransferReversal.retrieve" do
should "support requests with args: parent_id, id" do
Stripe::Transfer.retrieve_reversal(
"tr_xxxxxxxxxxxxx",
"trr_xxxxxxxxxxxxx"
)
assert_requested :get, "#{Stripe.api_base}/v1/transfers/tr_xxxxxxxxxxxxx/reversals/trr_xxxxxxxxxxxxx?"
end
end
context "TransferReversal.update" do
should "support requests with args: metadata, parent_id, id" do
Stripe::Transfer.update_reversal(
"tr_xxxxxxxxxxxxx",
"trr_xxxxxxxxxxxxx",
{ metadata: { order_id: "6735" } }
)
assert_requested :post, "#{Stripe.api_base}/v1/transfers/tr_xxxxxxxxxxxxx/reversals/trr_xxxxxxxxxxxxx"
end
end
context "ValueList.create" do
should "support requests with args: alias, name, item_type" do
Stripe::Radar::ValueList.create(
Expand Down