Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
efcasado committed May 11, 2024
1 parent a2f828e commit 6adb7ca
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 56 deletions.
23 changes: 23 additions & 0 deletions test/uof/api/descriptions/bet_stop_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
defmodule UOF.API.Descriptions.BetStop.Test do
use ExUnit.Case

setup do
:ok = Application.put_env(:tesla, UOF.API, adapter: Tesla.Mock)

Tesla.Mock.mock(fn
%{method: :get} ->
resp = File.read!("test/data/betstop_reasons.xml")
%Tesla.Env{status: 200, headers: [{"content-type", "application/xml"}], body: resp}
end)

:ok
end

test "can parse UOF.API.Descriptions.BetStop.all/0 response" do
resp = UOF.API.Descriptions.BetStop.all()

assert Enum.count(resp) == 90
assert hd(resp).id == 0
assert hd(resp).description == :UNKNOWN
end
end
23 changes: 23 additions & 0 deletions test/uof/api/descriptions/betting_status_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
defmodule UOF.API.Descriptions.BettingStatus.Test do
use ExUnit.Case

setup do
:ok = Application.put_env(:tesla, UOF.API, adapter: Tesla.Mock)

Tesla.Mock.mock(fn
%{method: :get} ->
resp = File.read!("test/data/betting_status.xml")
%Tesla.Env{status: 200, headers: [{"content-type", "application/xml"}], body: resp}
end)

:ok
end

test "can parse UOF.API.Descriptions.BettingStatus.all/0 response" do
resp = UOF.API.Descriptions.BettingStatus.all()

assert Enum.count(resp) == 7
assert hd(resp).id == 0
assert hd(resp).description == :UNKNOWN
end
end
47 changes: 47 additions & 0 deletions test/uof/api/descriptions/match_status_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
defmodule UOF.API.Descriptions.MatchStatus.Test do
use ExUnit.Case

setup do
:ok = Application.put_env(:tesla, UOF.API, adapter: Tesla.Mock)

Tesla.Mock.mock(fn
%{method: :get} ->
resp = File.read!("test/data/match_status.xml")
%Tesla.Env{status: 200, headers: [{"content-type", "application/xml"}], body: resp}
end)

:ok
end

test "can parse UOF.API.Descriptions.MatchStatus/0 response" do
resp = UOF.API.Descriptions.MatchStatus.all()

assert Enum.count(resp) == 185

assert Enum.at(resp, 0).id == 0
assert Enum.at(resp, 0).description == "Not started"
assert Enum.at(resp, 0).period_number == nil
assert Enum.at(resp, 0).sports.all == true
assert Enum.at(resp, 0).sports.ids == []

assert Enum.at(resp, 1).id == 1
assert Enum.at(resp, 1).description == "1st period"
assert Enum.at(resp, 1).period_number == 1
assert Enum.at(resp, 1).sports.all == false

assert Enum.at(resp, 1).sports.ids ==
[
"sr:sport:2",
"sr:sport:4",
"sr:sport:7",
"sr:sport:13",
"sr:sport:24",
"sr:sport:32",
"sr:sport:34",
"sr:sport:131",
"sr:sport:153",
"sr:sport:157",
"sr:sport:195"
]
end
end
56 changes: 0 additions & 56 deletions test/uof/api/descriptions_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -27,62 +27,6 @@ defmodule UOF.API.Descriptions.Test do
assert Enum.map(market.outcomes, & &1.id) == ["13", "12"]
end

test "can parse UOF.API.Descriptions.match_statuses/{0, 1} response" do
{:ok, desc} = UOF.API.Descriptions.match_statuses()

assert Enum.count(desc.statuses) == 185

status1 = Enum.at(desc.statuses, 0)

assert status1.id == 0
assert status1.description == "Not started"
assert status1.period_number == nil
assert status1.all_sports == true
assert status1.sports == []

status2 = Enum.at(desc.statuses, 1)

assert status2.id == 1
assert status2.description == "1st period"
assert status2.period_number == 1
assert status2.all_sports == false

assert Enum.map(status2.sports, & &1.id) ==
[
"sr:sport:2",
"sr:sport:4",
"sr:sport:7",
"sr:sport:13",
"sr:sport:24",
"sr:sport:32",
"sr:sport:34",
"sr:sport:131",
"sr:sport:153",
"sr:sport:157",
"sr:sport:195"
]
end

test "can parse UOF.API.Descriptions.betstop_reasons/0 response" do
{:ok, desc} = UOF.API.Descriptions.betstop_reasons()

reason = hd(desc.reasons)

assert Enum.count(desc.reasons) == 90
assert reason.id == 0
assert reason.description == "UNKNOWN"
end

test "can parse UOF.API.Descriptions.betting_statuses/0 response" do
{:ok, desc} = UOF.API.Descriptions.betting_statuses()

status = hd(desc.statuses)

assert Enum.count(desc.statuses) == 7
assert status.id == 0
assert status.description == "UNKNOWN"
end

test "can parse UOF.API.Descriptions.void_reasons/0 response" do
{:ok, desc} = UOF.API.Descriptions.void_reasons()

Expand Down

0 comments on commit 6adb7ca

Please sign in to comment.