2024-03-27 09:16:00 -06:00
|
|
|
require "test_helper"
|
2024-07-08 09:04:59 -04:00
|
|
|
require "ostruct"
|
2024-03-27 09:16:00 -06:00
|
|
|
|
|
|
|
class Provider::SynthTest < ActiveSupport::TestCase
|
2025-03-17 11:54:53 -04:00
|
|
|
include ExchangeRateProviderInterfaceTest, SecurityProviderInterfaceTest
|
2024-03-27 09:16:00 -06:00
|
|
|
|
|
|
|
setup do
|
2024-08-01 19:43:23 -04:00
|
|
|
@subject = @synth = Provider::Synth.new(ENV["SYNTH_API_KEY"])
|
|
|
|
end
|
|
|
|
|
2025-03-17 11:54:53 -04:00
|
|
|
test "health check" do
|
|
|
|
VCR.use_cassette("synth/health") do
|
|
|
|
assert @synth.healthy?
|
2024-08-01 19:43:23 -04:00
|
|
|
end
|
2024-07-08 09:04:59 -04:00
|
|
|
end
|
|
|
|
|
2025-03-17 11:54:53 -04:00
|
|
|
test "usage info" do
|
|
|
|
VCR.use_cassette("synth/usage") do
|
|
|
|
usage = @synth.usage.data
|
|
|
|
assert usage.used.present?
|
|
|
|
assert usage.limit.present?
|
|
|
|
assert usage.utilization.present?
|
|
|
|
assert usage.plan.present?
|
2024-08-09 16:57:33 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2025-03-17 11:54:53 -04:00
|
|
|
test "enriches transaction" do
|
|
|
|
VCR.use_cassette("synth/transaction_enrich") do
|
|
|
|
response = @synth.enrich_transaction(
|
|
|
|
"UBER EATS",
|
|
|
|
amount: 25.50,
|
|
|
|
date: Date.iso8601("2025-03-16"),
|
|
|
|
city: "San Francisco",
|
|
|
|
state: "CA",
|
|
|
|
country: "US"
|
|
|
|
)
|
2024-07-08 09:04:59 -04:00
|
|
|
|
2025-03-17 11:54:53 -04:00
|
|
|
data = response.data
|
|
|
|
assert data.name.present?
|
|
|
|
assert data.category.present?
|
2024-07-08 09:04:59 -04:00
|
|
|
end
|
2024-03-27 09:16:00 -06:00
|
|
|
end
|
|
|
|
end
|