Skip to content

Commit

Permalink
Fixes test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
sle-c committed Jan 3, 2025
1 parent a6dca30 commit 7a24f6a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion lib/shopify_api/rest/resources/2025_01/fulfillment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def initialize(session: ShopifyAPI::Context.active_session, from_hash: nil)
@name = T.let(nil, T.nilable(String))
@notify_customer = T.let(nil, T.nilable(T::Boolean))
@order_id = T.let(nil, T.nilable(Integer))
@origin_address = T.let(nil, T.nilable(T::Array[T.untyped]))
@origin_address = T.let(nil, T.nilable(T::Hash[T.untyped, T.untyped]))
@receipt = T.let(nil, T.nilable(T::Hash[T.untyped, T.untyped]))
@service = T.let(nil, T.nilable(String))
@shipment_status = T.let(nil, T.nilable(String))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def initialize(session: ShopifyAPI::Context.active_session, from_hash: nil)

@app_clip_application_id = T.let(nil, T.nilable(String))
@application_id = T.let(nil, T.nilable(String))
@enabled_app_clips = T.let(nil, T.nilable(T::Hash[T.untyped, T.untyped]))
@enabled_app_clips = T.let(nil, T.nilable(T::Boolean))
@enabled_shared_webcredentials = T.let(nil, T.nilable(T::Boolean))
@enabled_universal_or_app_links = T.let(nil, T.nilable(T::Boolean))
@id = T.let(nil, T.nilable(Integer))
Expand All @@ -44,7 +44,7 @@ def initialize(session: ShopifyAPI::Context.active_session, from_hash: nil)
attr_reader :app_clip_application_id
sig { returns(T.nilable(String)) }
attr_reader :application_id
sig { returns(T.nilable(T::Hash[T.untyped, T.untyped])) }
sig { returns(T.nilable(T::Boolean)) }
attr_reader :enabled_app_clips
sig { returns(T.nilable(T::Boolean)) }
attr_reader :enabled_shared_webcredentials
Expand Down
58 changes: 29 additions & 29 deletions test/rest/2025_01/webhook_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
require "shopify_api"
require_relative "../../test_helper"

class Webhook202410Test < Test::Unit::TestCase
class Webhook202501Test < Test::Unit::TestCase
def setup
super

test_session = ShopifyAPI::Auth::Session.new(id: "id", shop: "test-shop.myshopify.io", access_token: "this_is_a_test_token")
ShopifyAPI::Context.activate_session(test_session)
modify_context(api_version: "2024-10")
modify_context(api_version: "2025-01")
end

def teardown
Expand All @@ -33,16 +33,16 @@ def teardown
void
end
def test_1()
stub_request(:get, "https://test-shop.myshopify.io/admin/api/2024-10/webhooks.json")
stub_request(:get, "https://test-shop.myshopify.io/admin/api/2025-01/webhooks.json")
.with(
headers: {"X-Shopify-Access-Token"=>"this_is_a_test_token", "Accept"=>"application/json"},
body: {}
)
.to_return(status: 200, body: JSON.generate({"webhooks" => [{"id" => 4759306, "address" => "https://apple.com", "topic" => "orders/create", "created_at" => "2024-10-02T08:59:11-05:00", "updated_at" => "2024-10-02T08:59:11-05:00", "format" => "json", "fields" => [], "metafield_namespaces" => [], "api_version" => "unstable", "private_metafield_namespaces" => []}, {"id" => 892403750, "address" => "https://example.org/fully_loaded_1", "topic" => "orders/cancelled", "created_at" => "2021-12-01T05:23:43-05:00", "updated_at" => "2021-12-01T05:23:43-05:00", "format" => "json", "fields" => [], "metafield_namespaces" => [], "api_version" => "unstable", "private_metafield_namespaces" => []}, {"id" => 901431826, "address" => "https://apple.com/uninstall", "topic" => "app/uninstalled", "created_at" => "2024-10-02T08:59:11-05:00", "updated_at" => "2024-10-02T08:59:11-05:00", "format" => "json", "fields" => [], "metafield_namespaces" => [], "api_version" => "unstable", "private_metafield_namespaces" => []}, {"id" => 1014196360, "address" => "https://example.org/app_uninstalled", "topic" => "app/uninstalled", "created_at" => "2024-10-02T08:59:11-05:00", "updated_at" => "2024-10-02T08:59:11-05:00", "format" => "json", "fields" => [], "metafield_namespaces" => [], "api_version" => "unstable", "private_metafield_namespaces" => []}]}), headers: {})
.to_return(status: 200, body: JSON.generate({"webhooks" => [{"id" => 4759306, "address" => "https://apple.com", "topic" => "orders/create", "created_at" => "2025-01-02T08:59:11-05:00", "updated_at" => "2025-01-02T08:59:11-05:00", "format" => "json", "fields" => [], "metafield_namespaces" => [], "api_version" => "unstable", "private_metafield_namespaces" => []}, {"id" => 892403750, "address" => "https://example.org/fully_loaded_1", "topic" => "orders/cancelled", "created_at" => "2021-12-01T05:23:43-05:00", "updated_at" => "2021-12-01T05:23:43-05:00", "format" => "json", "fields" => [], "metafield_namespaces" => [], "api_version" => "unstable", "private_metafield_namespaces" => []}, {"id" => 901431826, "address" => "https://apple.com/uninstall", "topic" => "app/uninstalled", "created_at" => "2025-01-02T08:59:11-05:00", "updated_at" => "2025-01-02T08:59:11-05:00", "format" => "json", "fields" => [], "metafield_namespaces" => [], "api_version" => "unstable", "private_metafield_namespaces" => []}, {"id" => 1014196360, "address" => "https://example.org/app_uninstalled", "topic" => "app/uninstalled", "created_at" => "2025-01-02T08:59:11-05:00", "updated_at" => "2025-01-02T08:59:11-05:00", "format" => "json", "fields" => [], "metafield_namespaces" => [], "api_version" => "unstable", "private_metafield_namespaces" => []}]}), headers: {})

response = ShopifyAPI::Webhook.all

assert_requested(:get, "https://test-shop.myshopify.io/admin/api/2024-10/webhooks.json")
assert_requested(:get, "https://test-shop.myshopify.io/admin/api/2025-01/webhooks.json")

response = response.first if response.respond_to?(:first)

Expand All @@ -63,18 +63,18 @@ def test_1()
void
end
def test_2()
stub_request(:get, "https://test-shop.myshopify.io/admin/api/2024-10/webhooks.json?since_id=901431826")
stub_request(:get, "https://test-shop.myshopify.io/admin/api/2025-01/webhooks.json?since_id=901431826")
.with(
headers: {"X-Shopify-Access-Token"=>"this_is_a_test_token", "Accept"=>"application/json"},
body: {}
)
.to_return(status: 200, body: JSON.generate({"webhooks" => [{"id" => 1014196360, "address" => "https://example.org/app_uninstalled", "topic" => "app/uninstalled", "created_at" => "2024-10-02T08:59:11-05:00", "updated_at" => "2024-10-02T08:59:11-05:00", "format" => "json", "fields" => [], "metafield_namespaces" => [], "api_version" => "unstable", "private_metafield_namespaces" => []}]}), headers: {})
.to_return(status: 200, body: JSON.generate({"webhooks" => [{"id" => 1014196360, "address" => "https://example.org/app_uninstalled", "topic" => "app/uninstalled", "created_at" => "2025-01-02T08:59:11-05:00", "updated_at" => "2025-01-02T08:59:11-05:00", "format" => "json", "fields" => [], "metafield_namespaces" => [], "api_version" => "unstable", "private_metafield_namespaces" => []}]}), headers: {})

response = ShopifyAPI::Webhook.all(
since_id: "901431826",
)

assert_requested(:get, "https://test-shop.myshopify.io/admin/api/2024-10/webhooks.json?since_id=901431826")
assert_requested(:get, "https://test-shop.myshopify.io/admin/api/2025-01/webhooks.json?since_id=901431826")

response = response.first if response.respond_to?(:first)

Expand All @@ -95,20 +95,20 @@ def test_2()
void
end
def test_3()
stub_request(:post, "https://test-shop.myshopify.io/admin/api/2024-10/webhooks.json")
stub_request(:post, "https://test-shop.myshopify.io/admin/api/2025-01/webhooks.json")
.with(
headers: {"X-Shopify-Access-Token"=>"this_is_a_test_token", "Accept"=>"application/json", "Content-Type"=>"application/json"},
body: { "webhook" => hash_including({"address" => "pubsub://projectName:topicName", "topic" => "customers/update", "format" => "json"}) }
)
.to_return(status: 200, body: JSON.generate({"webhook" => {"id" => 6883828544, "address" => "pubsub://projectName:topicName", "topic" => "customers/update", "created_at" => "2024-10-02T09:06:06-05:00", "updated_at" => "2024-10-02T09:06:06-05:00", "format" => "json", "fields" => [], "metafield_namespaces" => [], "api_version" => "unstable", "private_metafield_namespaces" => []}}), headers: {})
.to_return(status: 200, body: JSON.generate({"webhook" => {"id" => 6883828544, "address" => "pubsub://projectName:topicName", "topic" => "customers/update", "created_at" => "2025-01-02T09:06:06-05:00", "updated_at" => "2025-01-02T09:06:06-05:00", "format" => "json", "fields" => [], "metafield_namespaces" => [], "api_version" => "unstable", "private_metafield_namespaces" => []}}), headers: {})

response = webhook = ShopifyAPI::Webhook.new
webhook.address = "pubsub://projectName:topicName"
webhook.topic = "customers/update"
webhook.format = "json"
webhook.save

assert_requested(:post, "https://test-shop.myshopify.io/admin/api/2024-10/webhooks.json")
assert_requested(:post, "https://test-shop.myshopify.io/admin/api/2025-01/webhooks.json")

response = response.first if response.respond_to?(:first)

Expand All @@ -129,20 +129,20 @@ def test_3()
void
end
def test_4()
stub_request(:post, "https://test-shop.myshopify.io/admin/api/2024-10/webhooks.json")
stub_request(:post, "https://test-shop.myshopify.io/admin/api/2025-01/webhooks.json")
.with(
headers: {"X-Shopify-Access-Token"=>"this_is_a_test_token", "Accept"=>"application/json", "Content-Type"=>"application/json"},
body: { "webhook" => hash_including({"address" => "arn:aws:events:us-east-1::event-source/aws.partner/shopify.com/755357713/example-event-source", "topic" => "customers/update", "format" => "json"}) }
)
.to_return(status: 200, body: JSON.generate({"webhook" => {"id" => 6883828534, "address" => "arn:aws:events:us-east-1::event-source/aws.partner/shopify.com/755357713/example-event-source", "topic" => "customers/update", "created_at" => "2024-10-02T09:05:41-05:00", "updated_at" => "2024-10-02T09:05:41-05:00", "format" => "json", "fields" => [], "metafield_namespaces" => [], "api_version" => "unstable", "private_metafield_namespaces" => []}}), headers: {})
.to_return(status: 200, body: JSON.generate({"webhook" => {"id" => 6883828534, "address" => "arn:aws:events:us-east-1::event-source/aws.partner/shopify.com/755357713/example-event-source", "topic" => "customers/update", "created_at" => "2025-01-02T09:05:41-05:00", "updated_at" => "2025-01-02T09:05:41-05:00", "format" => "json", "fields" => [], "metafield_namespaces" => [], "api_version" => "unstable", "private_metafield_namespaces" => []}}), headers: {})

response = webhook = ShopifyAPI::Webhook.new
webhook.address = "arn:aws:events:us-east-1::event-source/aws.partner/shopify.com/755357713/example-event-source"
webhook.topic = "customers/update"
webhook.format = "json"
webhook.save

assert_requested(:post, "https://test-shop.myshopify.io/admin/api/2024-10/webhooks.json")
assert_requested(:post, "https://test-shop.myshopify.io/admin/api/2025-01/webhooks.json")

response = response.first if response.respond_to?(:first)

Expand All @@ -163,12 +163,12 @@ def test_4()
void
end
def test_5()
stub_request(:post, "https://test-shop.myshopify.io/admin/api/2024-10/webhooks.json")
stub_request(:post, "https://test-shop.myshopify.io/admin/api/2025-01/webhooks.json")
.with(
headers: {"X-Shopify-Access-Token"=>"this_is_a_test_token", "Accept"=>"application/json", "Content-Type"=>"application/json"},
body: { "webhook" => hash_including({"topic" => "orders/create", "address" => "https://example.hostname.com/", "format" => "json", "fields" => ["id", "note"]}) }
)
.to_return(status: 200, body: JSON.generate({"webhook" => {"id" => 6883828554, "address" => "https://example.hostname.com/", "topic" => "orders/create", "created_at" => "2024-10-02T09:06:30-05:00", "updated_at" => "2024-10-02T09:06:30-05:00", "format" => "json", "fields" => ["id", "note"], "metafield_namespaces" => [], "api_version" => "unstable", "private_metafield_namespaces" => []}}), headers: {})
.to_return(status: 200, body: JSON.generate({"webhook" => {"id" => 6883828554, "address" => "https://example.hostname.com/", "topic" => "orders/create", "created_at" => "2025-01-02T09:06:30-05:00", "updated_at" => "2025-01-02T09:06:30-05:00", "format" => "json", "fields" => ["id", "note"], "metafield_namespaces" => [], "api_version" => "unstable", "private_metafield_namespaces" => []}}), headers: {})

response = webhook = ShopifyAPI::Webhook.new
webhook.topic = "orders/create"
Expand All @@ -180,7 +180,7 @@ def test_5()
]
webhook.save

assert_requested(:post, "https://test-shop.myshopify.io/admin/api/2024-10/webhooks.json")
assert_requested(:post, "https://test-shop.myshopify.io/admin/api/2025-01/webhooks.json")

response = response.first if response.respond_to?(:first)

Expand All @@ -201,7 +201,7 @@ def test_5()
void
end
def test_6()
stub_request(:get, "https://test-shop.myshopify.io/admin/api/2024-10/webhooks/count.json?topic=orders%2Fcreate")
stub_request(:get, "https://test-shop.myshopify.io/admin/api/2025-01/webhooks/count.json?topic=orders%2Fcreate")
.with(
headers: {"X-Shopify-Access-Token"=>"this_is_a_test_token", "Accept"=>"application/json"},
body: {}
Expand All @@ -212,7 +212,7 @@ def test_6()
topic: "orders/create",
)

assert_requested(:get, "https://test-shop.myshopify.io/admin/api/2024-10/webhooks/count.json?topic=orders%2Fcreate")
assert_requested(:get, "https://test-shop.myshopify.io/admin/api/2025-01/webhooks/count.json?topic=orders%2Fcreate")

response = response.first if response.respond_to?(:first)

Expand All @@ -233,7 +233,7 @@ def test_6()
void
end
def test_7()
stub_request(:get, "https://test-shop.myshopify.io/admin/api/2024-10/webhooks/count.json")
stub_request(:get, "https://test-shop.myshopify.io/admin/api/2025-01/webhooks/count.json")
.with(
headers: {"X-Shopify-Access-Token"=>"this_is_a_test_token", "Accept"=>"application/json"},
body: {}
Expand All @@ -242,7 +242,7 @@ def test_7()

response = ShopifyAPI::Webhook.count

assert_requested(:get, "https://test-shop.myshopify.io/admin/api/2024-10/webhooks/count.json")
assert_requested(:get, "https://test-shop.myshopify.io/admin/api/2025-01/webhooks/count.json")

response = response.first if response.respond_to?(:first)

Expand All @@ -263,18 +263,18 @@ def test_7()
void
end
def test_8()
stub_request(:get, "https://test-shop.myshopify.io/admin/api/2024-10/webhooks/4759306.json")
stub_request(:get, "https://test-shop.myshopify.io/admin/api/2025-01/webhooks/4759306.json")
.with(
headers: {"X-Shopify-Access-Token"=>"this_is_a_test_token", "Accept"=>"application/json"},
body: {}
)
.to_return(status: 200, body: JSON.generate({"webhook" => {"id" => 4759306, "address" => "https://apple.com", "topic" => "orders/create", "created_at" => "2024-10-02T08:59:11-05:00", "updated_at" => "2024-10-02T08:59:11-05:00", "format" => "json", "fields" => [], "metafield_namespaces" => [], "api_version" => "unstable", "private_metafield_namespaces" => []}}), headers: {})
.to_return(status: 200, body: JSON.generate({"webhook" => {"id" => 4759306, "address" => "https://apple.com", "topic" => "orders/create", "created_at" => "2025-01-02T08:59:11-05:00", "updated_at" => "2025-01-02T08:59:11-05:00", "format" => "json", "fields" => [], "metafield_namespaces" => [], "api_version" => "unstable", "private_metafield_namespaces" => []}}), headers: {})

response = ShopifyAPI::Webhook.find(
id: 4759306,
)

assert_requested(:get, "https://test-shop.myshopify.io/admin/api/2024-10/webhooks/4759306.json")
assert_requested(:get, "https://test-shop.myshopify.io/admin/api/2025-01/webhooks/4759306.json")

response = response.first if response.respond_to?(:first)

Expand All @@ -295,19 +295,19 @@ def test_8()
void
end
def test_9()
stub_request(:put, "https://test-shop.myshopify.io/admin/api/2024-10/webhooks/4759306.json")
stub_request(:put, "https://test-shop.myshopify.io/admin/api/2025-01/webhooks/4759306.json")
.with(
headers: {"X-Shopify-Access-Token"=>"this_is_a_test_token", "Accept"=>"application/json", "Content-Type"=>"application/json"},
body: { "webhook" => hash_including({"address" => "https://somewhere-else.com/"}) }
)
.to_return(status: 200, body: JSON.generate({"webhook" => {"id" => 4759306, "address" => "https://somewhere-else.com/", "topic" => "orders/create", "created_at" => "2024-10-02T08:59:11-05:00", "updated_at" => "2024-10-02T09:08:15-05:00", "format" => "json", "fields" => [], "metafield_namespaces" => [], "api_version" => "unstable", "private_metafield_namespaces" => []}}), headers: {})
.to_return(status: 200, body: JSON.generate({"webhook" => {"id" => 4759306, "address" => "https://somewhere-else.com/", "topic" => "orders/create", "created_at" => "2025-01-02T08:59:11-05:00", "updated_at" => "2025-01-02T09:08:15-05:00", "format" => "json", "fields" => [], "metafield_namespaces" => [], "api_version" => "unstable", "private_metafield_namespaces" => []}}), headers: {})

response = webhook = ShopifyAPI::Webhook.new
webhook.id = 4759306
webhook.address = "https://somewhere-else.com/"
webhook.save

assert_requested(:put, "https://test-shop.myshopify.io/admin/api/2024-10/webhooks/4759306.json")
assert_requested(:put, "https://test-shop.myshopify.io/admin/api/2025-01/webhooks/4759306.json")

response = response.first if response.respond_to?(:first)

Expand All @@ -328,7 +328,7 @@ def test_9()
void
end
def test_10()
stub_request(:delete, "https://test-shop.myshopify.io/admin/api/2024-10/webhooks/4759306.json")
stub_request(:delete, "https://test-shop.myshopify.io/admin/api/2025-01/webhooks/4759306.json")
.with(
headers: {"X-Shopify-Access-Token"=>"this_is_a_test_token", "Accept"=>"application/json"},
body: {}
Expand All @@ -339,7 +339,7 @@ def test_10()
id: 4759306,
)

assert_requested(:delete, "https://test-shop.myshopify.io/admin/api/2024-10/webhooks/4759306.json")
assert_requested(:delete, "https://test-shop.myshopify.io/admin/api/2025-01/webhooks/4759306.json")

response = response.first if response.respond_to?(:first)

Expand Down

0 comments on commit 7a24f6a

Please sign in to comment.