summaryrefslogtreecommitdiff
path: root/test/polyjuice
diff options
context:
space:
mode:
authorHubert Chathi <hubert@uhoreg.ca>2020-12-26 21:32:44 -0500
committerHubert Chathi <hubert@uhoreg.ca>2020-12-26 21:32:44 -0500
commitd11baa1ab6628781506ad17936dfcd5a9afd0821 (patch)
tree9c659069e71f84fd4ac9b9761115eb6e0190f3b7 /test/polyjuice
parentfix warnings in test (diff)
add function for getting user/device ID
and use it when the user ID is unspecified when setting/getting account data
Diffstat (limited to 'test/polyjuice')
-rw-r--r--test/polyjuice/client/account_test.exs35
-rw-r--r--test/polyjuice/client_test.exs17
2 files changed, 48 insertions, 4 deletions
diff --git a/test/polyjuice/client/account_test.exs b/test/polyjuice/client/account_test.exs
index 6f11d25..4a21df4 100644
--- a/test/polyjuice/client/account_test.exs
+++ b/test/polyjuice/client/account_test.exs
@@ -20,14 +20,28 @@ defmodule Polyjuice.Client.AccountTest do
with client = %DummyClient{
response: {
%Polyjuice.Client.Endpoint.GetAccountData{
- user_id: "toto@kazarma.local",
+ user_id: "@toto:kazarma.local",
type: "name"
},
{:ok, %{name: "toto"}}
}
} do
{:ok, %{name: name}} =
- Polyjuice.Client.Account.get_data(client, "toto@kazarma.local", "name")
+ Polyjuice.Client.Account.get_data(client, "@toto:kazarma.local", "name")
+
+ assert name == "toto"
+ end
+
+ with client = %DummyClient{
+ response: {
+ %Polyjuice.Client.Endpoint.GetAccountData{
+ user_id: "@alice:example.org",
+ type: "name"
+ },
+ {:ok, %{name: "toto"}}
+ }
+ } do
+ {:ok, %{name: name}} = Polyjuice.Client.Account.get_data(client, "name")
assert name == "toto"
end
@@ -37,7 +51,7 @@ defmodule Polyjuice.Client.AccountTest do
with client = %DummyClient{
response: {
%Polyjuice.Client.Endpoint.PutAccountData{
- user_id: "toto@kazarma.local",
+ user_id: "@toto:kazarma.local",
type: "name",
account_data: %{name: "marc"}
},
@@ -45,7 +59,20 @@ defmodule Polyjuice.Client.AccountTest do
}
} do
{:ok, %{}} =
- Polyjuice.Client.Account.put_data(client, "toto@kazarma.local", "name", %{name: "marc"})
+ Polyjuice.Client.Account.put_data(client, "@toto:kazarma.local", "name", %{name: "marc"})
+ end
+
+ with client = %DummyClient{
+ response: {
+ %Polyjuice.Client.Endpoint.PutAccountData{
+ user_id: "@alice:example.org",
+ type: "name",
+ account_data: %{name: "marc"}
+ },
+ {:ok, %{}}
+ }
+ } do
+ {:ok, %{}} = Polyjuice.Client.Account.put_data(client, "name", %{name: "marc"})
end
end
end
diff --git a/test/polyjuice/client_test.exs b/test/polyjuice/client_test.exs
index c516096..089c97f 100644
--- a/test/polyjuice/client_test.exs
+++ b/test/polyjuice/client_test.exs
@@ -423,4 +423,21 @@ defmodule Polyjuice.ClientTest do
File.rm_rf(tmpdir)
end
end
+
+ test "gets the user and device IDs" do
+ {:ok, client_pid} =
+ Polyjuice.Client.start_link(
+ "",
+ access_token: nil,
+ sync: false,
+ handler: self(),
+ test: true,
+ user_id: "@alice:example.org",
+ device_id: "DEVICEID"
+ )
+
+ client = Polyjuice.Client.get_client(client_pid)
+
+ assert Polyjuice.Client.API.get_user_and_device(client) == {"@alice:example.org", "DEVICEID"}
+ end
end