Initial unit test
parent
ef69286f66
commit
31d5b9a086
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"id": 8039,
|
||||
"username": "milmazz",
|
||||
"acct": "milmazz",
|
||||
"display_name": "Milton Mazzarri",
|
||||
"locked": false,
|
||||
"created_at": "2017-04-06T17:43:55.325Z",
|
||||
"followers_count": 4,
|
||||
"following_count": 4,
|
||||
"statuses_count": 3,
|
||||
"note": "",
|
||||
"url": "https://social.lou.lt/@milmazz",
|
||||
"avatar": "https://social.lou.lt/avatars/original/missing.png",
|
||||
"avatar_static": "https://social.lou.lt/avatars/original/missing.png",
|
||||
"header": "https://social.lou.lt/headers/original/missing.png",
|
||||
"header_static": "https://social.lou.lt/headers/original/missing.png"
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"acct": "paperswelove@mstdn.io",
|
||||
"avatar": "https://social.lou.lt/system/accounts/avatars/000/007/126/original/60ecc8225809c008.png?1491486258",
|
||||
"created_at": "2017-04-06T13:44:18.281Z",
|
||||
"display_name": "Papers We Love",
|
||||
"followers_count": 1,
|
||||
"following_count": 0,
|
||||
"header": "https://social.lou.lt/system/accounts/headers/000/007/126/original/missing.png?1491486258",
|
||||
"id": 7126,
|
||||
"locked": false,
|
||||
"note": "Building Bridges Between Academia and Industry\r\n\r\n<a href=\"http://paperswelove.org\" rel=\"nofollow noopener\"><span class=\"invisible\">http://</span><span class=\"\">paperswelove.org</span><span class=\"invisible\"></span></a>\r\n<a href=\"http://pwlconf.org\" rel=\"nofollow noopener noopener\"><span class=\"invisible\">http://</span><span class=\"\">pwlconf.org</span><span class=\"invisible\"></span></a>",
|
||||
"statuses_count": 1,
|
||||
"url": "https://mstdn.io/@paperswelove",
|
||||
"username": "paperswelove"
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
[
|
||||
{
|
||||
"id": 14825,
|
||||
"username": "kadaba",
|
||||
"acct": "kadaba@lavraievie.social",
|
||||
"display_name": "Kadaba ✅",
|
||||
"locked": false,
|
||||
"created_at": "2017-04-10T15:53:45.161Z",
|
||||
"followers_count": 1,
|
||||
"following_count": 2,
|
||||
"statuses_count": 25,
|
||||
"note": "¡Cagando...! Digo: ¡¡¡...Cargando...!!! Debugging with Prozac. =JDK= ⠠⠵",
|
||||
"url": "https://lavraievie.social/@kadaba",
|
||||
"avatar": "https://social.lou.lt/system/accounts/avatars/000/014/825/original/2acce7800f6d0366.jpeg?1491839628",
|
||||
"avatar_static": "https://social.lou.lt/system/accounts/avatars/000/014/825/original/2acce7800f6d0366.jpeg?1491839628",
|
||||
"header": "https://social.lou.lt/system/accounts/headers/000/014/825/original/missing.png?1491839631",
|
||||
"header_static": "https://social.lou.lt/system/accounts/headers/000/014/825/original/missing.png?1491839631"
|
||||
},
|
||||
{
|
||||
"id": 7126,
|
||||
"username": "paperswelove",
|
||||
"acct": "paperswelove@mstdn.io",
|
||||
"display_name": "Papers We Love",
|
||||
"locked": false,
|
||||
"created_at": "2017-04-06T13:44:18.281Z",
|
||||
"followers_count": 2,
|
||||
"following_count": 3,
|
||||
"statuses_count": 16,
|
||||
"note": "Building Bridges Between Academia and Industry\n\n<a href=\"http://paperswelove.org\" rel=\"nofollow noopener\"><span class=\"invisible\">http://</span><span class=\"\">paperswelove.org</span><span class=\"invisible\"></span></a>\n<a href=\"http://pwlconf.org\" rel=\"nofollow noopener noopener\"><span class=\"invisible\">http://</span><span class=\"\">pwlconf.org</span><span class=\"invisible\"></span></a>",
|
||||
"url": "https://mstdn.io/@paperswelove",
|
||||
"avatar": "https://social.lou.lt/system/accounts/avatars/000/007/126/original/60ecc8225809c008.png?1491486258",
|
||||
"avatar_static": "https://social.lou.lt/system/accounts/avatars/000/007/126/original/60ecc8225809c008.png?1491486258",
|
||||
"header": "https://social.lou.lt/system/accounts/headers/000/007/126/original/missing.png?1491486258",
|
||||
"header_static": "https://social.lou.lt/system/accounts/headers/000/007/126/original/missing.png?1491486258"
|
||||
},
|
||||
{
|
||||
"id": 8518,
|
||||
"username": "atmantree",
|
||||
"acct": "atmantree@mastodon.club",
|
||||
"display_name": "Carlos Gustavo Ruiz",
|
||||
"locked": false,
|
||||
"created_at": "2017-04-06T20:07:57.119Z",
|
||||
"followers_count": 2,
|
||||
"following_count": 2,
|
||||
"statuses_count": 0,
|
||||
"note": "Programmer, Pythonista, Web Creature, Blogger, C++ and Haskell Fan. Never stop learning, because life never stops teaching.",
|
||||
"url": "https://mastodon.club/@atmantree",
|
||||
"avatar": "https://social.lou.lt/system/accounts/avatars/000/008/518/original/7715529d4ceb4554.jpg?1491509276",
|
||||
"avatar_static": "https://social.lou.lt/system/accounts/avatars/000/008/518/original/7715529d4ceb4554.jpg?1491509276",
|
||||
"header": "https://social.lou.lt/system/accounts/headers/000/008/518/original/394f31473de7c64a.png?1491509277",
|
||||
"header_static": "https://social.lou.lt/system/accounts/headers/000/008/518/original/394f31473de7c64a.png?1491509277"
|
||||
},
|
||||
{
|
||||
"id": 4682,
|
||||
"username": "pankas87",
|
||||
"acct": "pankas87",
|
||||
"display_name": "Leonardo Graterol",
|
||||
"locked": false,
|
||||
"created_at": "2017-04-05T21:22:13.280Z",
|
||||
"followers_count": 18,
|
||||
"following_count": 20,
|
||||
"statuses_count": 37,
|
||||
"note": "I trade developing services for currency. Ruby fan, PHP mercenary, getting mind fucked by Scala. Venezuelan living in Chile\r\n\r\nLanguages: Spanish and English",
|
||||
"url": "https://social.lou.lt/@pankas87",
|
||||
"avatar": "https://social.lou.lt/system/accounts/avatars/000/004/682/original/7a5fc3a6f54c833e.jpg?1491428029",
|
||||
"avatar_static": "https://social.lou.lt/system/accounts/avatars/000/004/682/original/7a5fc3a6f54c833e.jpg?1491428029",
|
||||
"header": "https://social.lou.lt/headers/original/missing.png",
|
||||
"header_static": "https://social.lou.lt/headers/original/missing.png"
|
||||
}
|
||||
]
|
|
@ -0,0 +1,70 @@
|
|||
[
|
||||
{
|
||||
"id": 7126,
|
||||
"username": "paperswelove",
|
||||
"acct": "paperswelove@mstdn.io",
|
||||
"display_name": "Papers We Love",
|
||||
"locked": false,
|
||||
"created_at": "2017-04-06T13:44:18.281Z",
|
||||
"followers_count": 2,
|
||||
"following_count": 3,
|
||||
"statuses_count": 16,
|
||||
"note": "Building Bridges Between Academia and Industry\n\n<a href=\"http://paperswelove.org\" rel=\"nofollow noopener\"><span class=\"invisible\">http://</span><span class=\"\">paperswelove.org</span><span class=\"invisible\"></span></a>\n<a href=\"http://pwlconf.org\" rel=\"nofollow noopener noopener\"><span class=\"invisible\">http://</span><span class=\"\">pwlconf.org</span><span class=\"invisible\"></span></a>",
|
||||
"url": "https://mstdn.io/@paperswelove",
|
||||
"avatar": "https://social.lou.lt/system/accounts/avatars/000/007/126/original/60ecc8225809c008.png?1491486258",
|
||||
"avatar_static": "https://social.lou.lt/system/accounts/avatars/000/007/126/original/60ecc8225809c008.png?1491486258",
|
||||
"header": "https://social.lou.lt/system/accounts/headers/000/007/126/original/missing.png?1491486258",
|
||||
"header_static": "https://social.lou.lt/system/accounts/headers/000/007/126/original/missing.png?1491486258"
|
||||
},
|
||||
{
|
||||
"id": 8518,
|
||||
"username": "atmantree",
|
||||
"acct": "atmantree@mastodon.club",
|
||||
"display_name": "Carlos Gustavo Ruiz",
|
||||
"locked": false,
|
||||
"created_at": "2017-04-06T20:07:57.119Z",
|
||||
"followers_count": 2,
|
||||
"following_count": 2,
|
||||
"statuses_count": 0,
|
||||
"note": "Programmer, Pythonista, Web Creature, Blogger, C++ and Haskell Fan. Never stop learning, because life never stops teaching.",
|
||||
"url": "https://mastodon.club/@atmantree",
|
||||
"avatar": "https://social.lou.lt/system/accounts/avatars/000/008/518/original/7715529d4ceb4554.jpg?1491509276",
|
||||
"avatar_static": "https://social.lou.lt/system/accounts/avatars/000/008/518/original/7715529d4ceb4554.jpg?1491509276",
|
||||
"header": "https://social.lou.lt/system/accounts/headers/000/008/518/original/394f31473de7c64a.png?1491509277",
|
||||
"header_static": "https://social.lou.lt/system/accounts/headers/000/008/518/original/394f31473de7c64a.png?1491509277"
|
||||
},
|
||||
{
|
||||
"id": 4682,
|
||||
"username": "pankas87",
|
||||
"acct": "pankas87",
|
||||
"display_name": "Leonardo Graterol",
|
||||
"locked": false,
|
||||
"created_at": "2017-04-05T21:22:13.280Z",
|
||||
"followers_count": 18,
|
||||
"following_count": 20,
|
||||
"statuses_count": 37,
|
||||
"note": "I trade developing services for currency. Ruby fan, PHP mercenary, getting mind fucked by Scala. Venezuelan living in Chile\r\n\r\nLanguages: Spanish and English",
|
||||
"url": "https://social.lou.lt/@pankas87",
|
||||
"avatar": "https://social.lou.lt/system/accounts/avatars/000/004/682/original/7a5fc3a6f54c833e.jpg?1491428029",
|
||||
"avatar_static": "https://social.lou.lt/system/accounts/avatars/000/004/682/original/7a5fc3a6f54c833e.jpg?1491428029",
|
||||
"header": "https://social.lou.lt/headers/original/missing.png",
|
||||
"header_static": "https://social.lou.lt/headers/original/missing.png"
|
||||
},
|
||||
{
|
||||
"id": 7899,
|
||||
"username": "sebasmagri",
|
||||
"acct": "sebasmagri@mastodon.cloud",
|
||||
"display_name": "Sebastián Ramírez Magrí",
|
||||
"locked": false,
|
||||
"created_at": "2017-04-06T17:07:38.912Z",
|
||||
"followers_count": 2,
|
||||
"following_count": 1,
|
||||
"statuses_count": 7,
|
||||
"note": "",
|
||||
"url": "https://mastodon.cloud/@sebasmagri",
|
||||
"avatar": "https://social.lou.lt/system/accounts/avatars/000/007/899/original/19b4d8c1e9d4e68a.jpg?1491498458",
|
||||
"avatar_static": "https://social.lou.lt/system/accounts/avatars/000/007/899/original/19b4d8c1e9d4e68a.jpg?1491498458",
|
||||
"header": "https://social.lou.lt/system/accounts/headers/000/007/899/original/missing.png?1491498458",
|
||||
"header_static": "https://social.lou.lt/system/accounts/headers/000/007/899/original/missing.png?1491498458"
|
||||
}
|
||||
]
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"id": 8039,
|
||||
"username": "milmazz",
|
||||
"acct": "milmazz",
|
||||
"display_name": "Milton Mazzarri",
|
||||
"locked": false,
|
||||
"created_at": "2017-04-06T17:43:55.325Z",
|
||||
"followers_count": 4,
|
||||
"following_count": 4,
|
||||
"statuses_count": 3,
|
||||
"note": "",
|
||||
"url": "https://social.lou.lt/@milmazz",
|
||||
"avatar": "https://social.lou.lt/avatars/original/missing.png",
|
||||
"avatar_static": "https://social.lou.lt/avatars/original/missing.png",
|
||||
"header": "https://social.lou.lt/headers/original/missing.png",
|
||||
"header_static": "https://social.lou.lt/headers/original/missing.png"
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
defmodule Hunter.AccountTest do
|
||||
use ExUnit.Case, async: true
|
||||
|
||||
alias Hunter.Account
|
||||
|
||||
setup do
|
||||
[conn: Hunter.Client.new([base_url: "https://example.com", bearer_token: "123456"])]
|
||||
end
|
||||
|
||||
test "verify credentials", %{conn: conn} do
|
||||
assert %Account{username: "milmazz"} = Account.verify_credentials(conn)
|
||||
end
|
||||
|
||||
test "returns an account", %{conn: conn} do
|
||||
assert %Account{username: "milmazz"} = Account.account(conn, 8039)
|
||||
end
|
||||
|
||||
test "returns a collection of followers accounts", %{conn: conn} do
|
||||
collection = Account.followers(conn, 8039)
|
||||
assert %Account{username: "kadaba"} = List.first(collection)
|
||||
end
|
||||
|
||||
test "returns a collection of following accounts", %{conn: conn} do
|
||||
collection = Account.following(conn, 8039)
|
||||
assert %Account{username: "paperswelove"} = List.first(collection)
|
||||
end
|
||||
|
||||
test "following a remote user", %{conn: conn} do
|
||||
assert %Account{username: "paperswelove"} = Account.follow_by_uri(conn, "paperswelove@mstdn.io")
|
||||
end
|
||||
end
|
|
@ -5,25 +5,26 @@ defmodule Hunter.Api.InMemory do
|
|||
|
||||
@behaviour Hunter.Api
|
||||
|
||||
def verify_credentials(_) do
|
||||
%Hunter.Account{}
|
||||
end
|
||||
[
|
||||
%{name: :verify_credentials, arity: 1, as: %Hunter.Account{}},
|
||||
%{name: :account, arity: 2, as: %Hunter.Account{}},
|
||||
%{name: :followers, arity: 2, as: [%Hunter.Account{}]},
|
||||
%{name: :following, arity: 2, as: [%Hunter.Account{}]},
|
||||
%{name: :follow_by_uri, arity: 2, as: %Hunter.Account{}}
|
||||
]
|
||||
|> Enum.map(fn %{name: name, arity: arity, as: as} ->
|
||||
params = for _ <- 1..arity, do: {:_, [], nil}
|
||||
as = Macro.escape(as)
|
||||
|
||||
def account(_, _) do
|
||||
%Hunter.Account{}
|
||||
end
|
||||
def unquote(name)(unquote_splicing(params)) do
|
||||
file = unquote(name) |> to_string()
|
||||
|
||||
def followers(_, _) do
|
||||
[%Hunter.Account{}]
|
||||
end
|
||||
|
||||
def following(_, _) do
|
||||
[%Hunter.Account{}]
|
||||
end
|
||||
|
||||
def follow_by_uri(_, _) do
|
||||
%Hunter.Account{}
|
||||
end
|
||||
"../fixtures/#{file}.json"
|
||||
|> Path.expand(__DIR__)
|
||||
|> File.read!()
|
||||
|> Poison.decode!(as: unquote(as))
|
||||
end
|
||||
end)
|
||||
|
||||
def search_account(_, _) do
|
||||
[%Hunter.Account{}]
|
||||
|
|
Loading…
Reference in New Issue