diff --git a/test/uof/api/descriptions/bet_stop_test.exs b/test/uof/api/descriptions/bet_stop_test.exs new file mode 100644 index 0000000..2c4c3d8 --- /dev/null +++ b/test/uof/api/descriptions/bet_stop_test.exs @@ -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 diff --git a/test/uof/api/descriptions/betting_status_test.exs b/test/uof/api/descriptions/betting_status_test.exs new file mode 100644 index 0000000..19f361c --- /dev/null +++ b/test/uof/api/descriptions/betting_status_test.exs @@ -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 diff --git a/test/uof/api/descriptions/match_status_test.exs b/test/uof/api/descriptions/match_status_test.exs new file mode 100644 index 0000000..9a8c5c2 --- /dev/null +++ b/test/uof/api/descriptions/match_status_test.exs @@ -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 diff --git a/test/uof/api/descriptions_test.exs b/test/uof/api/descriptions_test.exs index 03373ab..12d0674 100644 --- a/test/uof/api/descriptions_test.exs +++ b/test/uof/api/descriptions_test.exs @@ -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()