Simplyfied and reduced calls in tests greatly.
the build was successful
Details
the build was successful
Details
This commit is contained in:
parent
2c6997827f
commit
5875adf5db
|
@ -26,88 +26,45 @@ using namespace Mastodon;
|
||||||
SCENARIO ("/api/v1/accounts/:id can be called successfully",
|
SCENARIO ("/api/v1/accounts/:id can be called successfully",
|
||||||
"[api][mastodon][pleroma][glitch-soc]")
|
"[api][mastodon][pleroma][glitch-soc]")
|
||||||
{
|
{
|
||||||
GIVEN ("instance, user id and return_call")
|
const char *envinstance = std::getenv("MASTODON_CPP_INSTANCE");
|
||||||
{
|
const string instance = (envinstance ? envinstance : "likeable.space");
|
||||||
const char *envinstance = std::getenv("MASTODON_CPP_INSTANCE");
|
const char *env_user_id = std::getenv("MASTODON_CPP_USER_ID");
|
||||||
const string instance = (envinstance ? envinstance : "likeable.space");
|
const string user_id = (env_user_id ? env_user_id : "9hnrrVPriLiLVAhfVo");
|
||||||
const char *env_user_id = std::getenv("MASTODON_CPP_USER_ID");
|
|
||||||
const string user_id =
|
|
||||||
(env_user_id ? env_user_id : "9hnrrVPriLiLVAhfVo");
|
|
||||||
|
|
||||||
|
GIVEN ("instance = " + instance + ", user ID = " + user_id)
|
||||||
|
{
|
||||||
|
Mastodon::Easy::API masto(instance, "");
|
||||||
return_call ret;
|
return_call ret;
|
||||||
|
Easy::Account account;
|
||||||
bool exception = false;
|
bool exception = false;
|
||||||
|
|
||||||
GIVEN ("Mastodon::API")
|
WHEN ("/api/v1/accounts/" + user_id + " is called")
|
||||||
{
|
{
|
||||||
Mastodon::API masto(instance, "");
|
try
|
||||||
bool username_found = false;
|
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/" + user_id + " is called")
|
|
||||||
{
|
{
|
||||||
try
|
ret = masto.get(API::v1::accounts_id,
|
||||||
{
|
{{ "id", { user_id }}});
|
||||||
ret = masto.get(API::v1::accounts_id,
|
account = Easy::Account(ret.answer);
|
||||||
{{ "id", { user_id }}});
|
|
||||||
username_found =
|
|
||||||
ret.answer.find("\"username\":\"")
|
|
||||||
!= std::string::npos;
|
|
||||||
}
|
|
||||||
catch (const std::exception &e)
|
|
||||||
{
|
|
||||||
exception = true;
|
|
||||||
WARN(e.what());
|
|
||||||
}
|
|
||||||
THEN("No exception is thrown")
|
|
||||||
{
|
|
||||||
REQUIRE_FALSE(exception);
|
|
||||||
}
|
|
||||||
THEN ("No errors are returned")
|
|
||||||
{
|
|
||||||
REQUIRE(ret.error_code == 0);
|
|
||||||
REQUIRE(ret.http_error_code == 200);
|
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE(username_found);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
catch (const std::exception &e)
|
||||||
|
|
||||||
GIVEN ("Mastodon::Easy::API")
|
|
||||||
{
|
|
||||||
Mastodon::Easy::API masto(instance, "");
|
|
||||||
Easy::Account account;
|
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/" + user_id + " is called")
|
|
||||||
{
|
{
|
||||||
try
|
exception = true;
|
||||||
{
|
WARN(e.what());
|
||||||
ret = masto.get(API::v1::accounts_id,
|
}
|
||||||
{{ "id", { user_id }}});
|
|
||||||
account = Easy::Account(ret.answer);
|
THEN("No exception is thrown")
|
||||||
}
|
AND_THEN ("No errors are returned")
|
||||||
catch (const std::exception &e)
|
AND_THEN ("Answer is valid")
|
||||||
{
|
AND_THEN ("The answer makes sense")
|
||||||
exception = true;
|
{
|
||||||
WARN(e.what());
|
REQUIRE_FALSE(exception);
|
||||||
}
|
|
||||||
THEN("No exception is thrown")
|
REQUIRE(ret.error_code == 0);
|
||||||
{
|
REQUIRE(ret.http_error_code == 200);
|
||||||
REQUIRE_FALSE(exception);
|
|
||||||
}
|
REQUIRE(account.valid());
|
||||||
THEN ("No errors are returned")
|
|
||||||
{
|
REQUIRE(account.id() == user_id);
|
||||||
REQUIRE(ret.error_code == 0);
|
|
||||||
REQUIRE(ret.http_error_code == 200);
|
|
||||||
}
|
|
||||||
THEN ("Answer is valid")
|
|
||||||
{
|
|
||||||
REQUIRE(account.valid());
|
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE(account.username() != "");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,103 +27,52 @@ using namespace Mastodon;
|
||||||
SCENARIO ("/api/v1/accounts/:id/follow can be called successfully",
|
SCENARIO ("/api/v1/accounts/:id/follow can be called successfully",
|
||||||
"[api][mastodon][pleroma][glitch-soc]")
|
"[api][mastodon][pleroma][glitch-soc]")
|
||||||
{
|
{
|
||||||
GIVEN ("instance, access token, user id and return_call")
|
const char *env_instance = std::getenv("MASTODON_CPP_INSTANCE");
|
||||||
|
const string instance = (env_instance ? env_instance : "likeable.space");
|
||||||
|
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
||||||
|
const char *env_user_id = std::getenv("MASTODON_CPP_USER_ID");
|
||||||
|
const string user_id = (env_user_id ? env_user_id : "9hnrrVPriLiLVAhfVo");
|
||||||
|
|
||||||
|
GIVEN ("instance = " + instance + ", user ID = " + user_id)
|
||||||
{
|
{
|
||||||
const char *env_instance = std::getenv("MASTODON_CPP_INSTANCE");
|
Mastodon::Easy::API masto(instance, access_token);
|
||||||
const string instance =
|
|
||||||
(env_instance ? env_instance : "likeable.space");
|
|
||||||
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
|
||||||
const char *env_user_id = std::getenv("MASTODON_CPP_USER_ID");
|
|
||||||
const string user_id =
|
|
||||||
(env_user_id ? env_user_id : "9hnrrVPriLiLVAhfVo");
|
|
||||||
|
|
||||||
return_call ret;
|
return_call ret;
|
||||||
|
Easy::Relationship relationship;
|
||||||
bool exception = false;
|
bool exception = false;
|
||||||
bool following_found = false;
|
|
||||||
bool error_found = false;
|
|
||||||
|
|
||||||
// You can't follow yourself, so we look for errors too.
|
|
||||||
|
|
||||||
REQUIRE (access_token != nullptr);
|
REQUIRE (access_token != nullptr);
|
||||||
|
|
||||||
GIVEN ("Mastodon::API")
|
WHEN ("/api/v1/accounts/" + user_id + "/follow is called")
|
||||||
{
|
{
|
||||||
Mastodon::API masto(instance, access_token);
|
try
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/" + user_id + "/follow is called")
|
|
||||||
{
|
{
|
||||||
try
|
ret = masto.post(API::v1::accounts_id_follow,
|
||||||
{
|
{
|
||||||
ret = masto.post(API::v1::accounts_id_follow,
|
{ "id", { user_id } },
|
||||||
{
|
});
|
||||||
{ "id", { user_id } },
|
relationship.from_string(ret.answer);
|
||||||
});
|
|
||||||
following_found =
|
|
||||||
ret.answer.find("\"following\":\"")
|
|
||||||
!= std::string::npos;
|
|
||||||
error_found = following_found =
|
|
||||||
ret.answer.find("\"error")
|
|
||||||
!= std::string::npos;
|
|
||||||
}
|
|
||||||
catch (const std::exception &e)
|
|
||||||
{
|
|
||||||
exception = true;
|
|
||||||
WARN(e.what());
|
|
||||||
}
|
|
||||||
THEN("No exception is thrown")
|
|
||||||
{
|
|
||||||
REQUIRE_FALSE(exception);
|
|
||||||
}
|
|
||||||
THEN ("No unexpected errors are returned")
|
|
||||||
{
|
|
||||||
REQUIRE((ret.error_code == 0
|
|
||||||
|| ret.error_code == 111));
|
|
||||||
REQUIRE((ret.http_error_code == 200
|
|
||||||
|| ret.http_error_code == 500));
|
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE((following_found || error_found));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
catch (const std::exception &e)
|
||||||
|
|
||||||
GIVEN ("Mastodon::Easy::API")
|
|
||||||
{
|
|
||||||
Mastodon::Easy::API masto(instance, access_token);
|
|
||||||
Easy::Relationship relationship;
|
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/" + user_id + "/follow is called")
|
|
||||||
{
|
{
|
||||||
try
|
exception = true;
|
||||||
{
|
WARN(e.what());
|
||||||
ret = masto.post(API::v1::accounts_id_follow,
|
}
|
||||||
{
|
|
||||||
{ "id", { user_id } },
|
THEN("No exception is thrown")
|
||||||
});
|
AND_THEN ("No unexpected errors are returned")
|
||||||
relationship.from_string(ret.answer);
|
AND_THEN ("The answer makes sense")
|
||||||
}
|
{
|
||||||
catch (const std::exception &e)
|
REQUIRE_FALSE(exception);
|
||||||
{
|
|
||||||
exception = true;
|
// You can't follow yourself, so we look for errors too.
|
||||||
WARN(e.what());
|
REQUIRE((ret.error_code == 0
|
||||||
}
|
|| ret.error_code == 111));
|
||||||
THEN("No exception is thrown")
|
REQUIRE((ret.http_error_code == 200
|
||||||
{
|
|| ret.http_error_code == 500));
|
||||||
REQUIRE_FALSE(exception);
|
|
||||||
}
|
REQUIRE((relationship.following()
|
||||||
THEN ("No unexpected errors are returned")
|
|| relationship.error() != ""));
|
||||||
{
|
|
||||||
REQUIRE((ret.error_code == 0
|
|
||||||
|| ret.error_code == 111));
|
|
||||||
REQUIRE((ret.http_error_code == 200
|
|
||||||
|| ret.http_error_code == 500));
|
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE((relationship.following()
|
|
||||||
|| relationship.error() != ""));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,111 +27,60 @@ using namespace Mastodon;
|
||||||
SCENARIO ("/api/v1/accounts/:id/followers can be called successfully",
|
SCENARIO ("/api/v1/accounts/:id/followers can be called successfully",
|
||||||
"[api][mastodon][pleroma][glitch-soc]")
|
"[api][mastodon][pleroma][glitch-soc]")
|
||||||
{
|
{
|
||||||
GIVEN ("instance, access token, user id and return_call")
|
const char *env_instance = std::getenv("MASTODON_CPP_INSTANCE");
|
||||||
{
|
const string instance = (env_instance ? env_instance : "likeable.space");
|
||||||
const char *env_instance = std::getenv("MASTODON_CPP_INSTANCE");
|
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
||||||
const string instance =
|
const char *env_user_id = std::getenv("MASTODON_CPP_USER_ID");
|
||||||
(env_instance ? env_instance : "likeable.space");
|
const string user_id = (env_user_id ? env_user_id : "9hnrrVPriLiLVAhfVo");
|
||||||
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
|
||||||
const char *env_user_id = std::getenv("MASTODON_CPP_USER_ID");
|
|
||||||
const string user_id =
|
|
||||||
(env_user_id ? env_user_id : "9hnrrVPriLiLVAhfVo");
|
|
||||||
|
|
||||||
|
GIVEN ("instance = " + instance + ", user ID = " + user_id)
|
||||||
|
{
|
||||||
|
Mastodon::Easy::API masto(instance, access_token);
|
||||||
return_call ret;
|
return_call ret;
|
||||||
|
Easy::Account account;
|
||||||
bool exception = false;
|
bool exception = false;
|
||||||
bool username_found = false;
|
|
||||||
|
|
||||||
REQUIRE (access_token != nullptr);
|
REQUIRE (access_token != nullptr);
|
||||||
|
|
||||||
GIVEN ("Mastodon::API")
|
WHEN ("/api/v1/accounts/" + user_id + "/followers is called")
|
||||||
{
|
{
|
||||||
Mastodon::API masto(instance, access_token);
|
try
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/" + user_id + "/followers is called")
|
|
||||||
{
|
{
|
||||||
try
|
ret = masto.get(API::v1::accounts_id_followers,
|
||||||
|
{
|
||||||
|
{ "id", { user_id } },
|
||||||
|
{ "limit", { "5" } }
|
||||||
|
});
|
||||||
|
if (ret.answer == "[]")
|
||||||
{
|
{
|
||||||
ret = masto.get(API::v1::accounts_id_followers,
|
WARN("No followers found.");
|
||||||
{
|
|
||||||
{ "id", { user_id } },
|
|
||||||
{ "limit", { "5" } }
|
|
||||||
});
|
|
||||||
if (ret.answer == "[]")
|
|
||||||
{
|
|
||||||
WARN("No followers found.");
|
|
||||||
}
|
|
||||||
username_found =
|
|
||||||
ret.answer.find("\"username\":\"")
|
|
||||||
!= std::string::npos;
|
|
||||||
}
|
}
|
||||||
catch (const std::exception &e)
|
else
|
||||||
{
|
{
|
||||||
exception = true;
|
account.from_string
|
||||||
WARN(e.what());
|
(Easy::json_array_to_vector(ret.answer).front());
|
||||||
}
|
|
||||||
THEN("No exception is thrown")
|
|
||||||
{
|
|
||||||
REQUIRE_FALSE(exception);
|
|
||||||
}
|
|
||||||
THEN ("No errors are returned")
|
|
||||||
{
|
|
||||||
REQUIRE(ret.error_code == 0);
|
|
||||||
REQUIRE(ret.http_error_code == 200);
|
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE(username_found);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
catch (const std::exception &e)
|
||||||
|
|
||||||
GIVEN ("Mastodon::Easy::API")
|
|
||||||
{
|
|
||||||
Mastodon::Easy::API masto(instance, access_token);
|
|
||||||
Easy::Account account;
|
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/" + user_id + "/followers is called")
|
|
||||||
{
|
{
|
||||||
try
|
exception = true;
|
||||||
{
|
WARN(e.what());
|
||||||
ret = masto.get(API::v1::accounts_id_followers,
|
}
|
||||||
{
|
|
||||||
{ "id", { user_id } },
|
THEN("No exception is thrown")
|
||||||
{ "limit", { "5" } }
|
AND_THEN ("No errors are returned")
|
||||||
});
|
AND_THEN ("Answer is valid")
|
||||||
if (ret.answer == "[]")
|
AND_THEN ("The answer makes sense")
|
||||||
{
|
{
|
||||||
WARN("No followers found.");
|
REQUIRE_FALSE(exception);
|
||||||
}
|
|
||||||
else
|
REQUIRE(ret.error_code == 0);
|
||||||
{
|
REQUIRE(ret.http_error_code == 200);
|
||||||
account.from_string
|
REQUIRE(account.valid());
|
||||||
(Easy::json_array_to_vector(ret.answer).front());
|
|
||||||
}
|
REQUIRE(account.username() != "");
|
||||||
}
|
|
||||||
catch (const std::exception &e)
|
|
||||||
{
|
|
||||||
exception = true;
|
|
||||||
WARN(e.what());
|
|
||||||
}
|
|
||||||
THEN("No exception is thrown")
|
|
||||||
{
|
|
||||||
REQUIRE_FALSE(exception);
|
|
||||||
}
|
|
||||||
THEN ("No errors are returned")
|
|
||||||
{
|
|
||||||
REQUIRE(ret.error_code == 0);
|
|
||||||
REQUIRE(ret.http_error_code == 200);
|
|
||||||
}
|
|
||||||
THEN ("Answer is valid")
|
|
||||||
{
|
|
||||||
REQUIRE(account.valid());
|
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE(account.username() != "");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,110 +27,59 @@ using namespace Mastodon;
|
||||||
SCENARIO ("/api/v1/accounts/:id/following can be called successfully",
|
SCENARIO ("/api/v1/accounts/:id/following can be called successfully",
|
||||||
"[api][mastodon][pleroma][glitch-soc]")
|
"[api][mastodon][pleroma][glitch-soc]")
|
||||||
{
|
{
|
||||||
GIVEN ("instance, access token, user id and return_call")
|
const char *env_instance = std::getenv("MASTODON_CPP_INSTANCE");
|
||||||
{
|
const string instance = (env_instance ? env_instance : "likeable.space");
|
||||||
const char *env_instance = std::getenv("MASTODON_CPP_INSTANCE");
|
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
||||||
const string instance =
|
const char *env_user_id = std::getenv("MASTODON_CPP_USER_ID");
|
||||||
(env_instance ? env_instance : "likeable.space");
|
const string user_id = (env_user_id ? env_user_id : "9hnrrVPriLiLVAhfVo");
|
||||||
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
|
||||||
const char *env_user_id = std::getenv("MASTODON_CPP_USER_ID");
|
|
||||||
const string user_id =
|
|
||||||
(env_user_id ? env_user_id : "9hnrrVPriLiLVAhfVo");
|
|
||||||
|
|
||||||
|
GIVEN ("instance = " + instance + ", user ID = " + user_id)
|
||||||
|
{
|
||||||
|
Mastodon::Easy::API masto(instance, access_token);
|
||||||
return_call ret;
|
return_call ret;
|
||||||
|
Easy::Account account;
|
||||||
bool exception = false;
|
bool exception = false;
|
||||||
bool username_found = false;
|
|
||||||
|
|
||||||
REQUIRE (access_token != nullptr);
|
REQUIRE (access_token != nullptr);
|
||||||
|
|
||||||
GIVEN ("Mastodon::API")
|
WHEN ("/api/v1/accounts/" + user_id + "/following is called")
|
||||||
{
|
{
|
||||||
Mastodon::API masto(instance, access_token);
|
try
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/" + user_id + "/following is called")
|
|
||||||
{
|
{
|
||||||
try
|
ret = masto.get(API::v1::accounts_id_following,
|
||||||
|
{
|
||||||
|
{ "id", { user_id } },
|
||||||
|
{ "limit", { "5" } }
|
||||||
|
});
|
||||||
|
if (ret.answer == "[]")
|
||||||
{
|
{
|
||||||
ret = masto.get(API::v1::accounts_id_following,
|
WARN("No followed found.");
|
||||||
{
|
|
||||||
{ "id", { user_id } },
|
|
||||||
{ "limit", { "5" } }
|
|
||||||
});
|
|
||||||
if (ret.answer == "[]")
|
|
||||||
{
|
|
||||||
WARN("No followed found.");
|
|
||||||
}
|
|
||||||
username_found =
|
|
||||||
ret.answer.find("\"username\":\"")
|
|
||||||
!= std::string::npos;
|
|
||||||
}
|
}
|
||||||
catch (const std::exception &e)
|
else
|
||||||
{
|
{
|
||||||
exception = true;
|
account.from_string
|
||||||
WARN(e.what());
|
(Easy::json_array_to_vector(ret.answer).front());
|
||||||
}
|
|
||||||
THEN("No exception is thrown")
|
|
||||||
{
|
|
||||||
REQUIRE_FALSE(exception);
|
|
||||||
}
|
|
||||||
THEN ("No errors are returned")
|
|
||||||
{
|
|
||||||
REQUIRE(ret.error_code == 0);
|
|
||||||
REQUIRE(ret.http_error_code == 200);
|
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE(username_found);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
catch (const std::exception &e)
|
||||||
|
|
||||||
GIVEN ("Mastodon::Easy::API")
|
|
||||||
{
|
|
||||||
Mastodon::Easy::API masto(instance, access_token);
|
|
||||||
Easy::Account account;
|
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/" + user_id + "/following is called")
|
|
||||||
{
|
{
|
||||||
try
|
exception = true;
|
||||||
{
|
WARN(e.what());
|
||||||
ret = masto.get(API::v1::accounts_id_following,
|
}
|
||||||
{
|
|
||||||
{ "id", { user_id } },
|
THEN("No exception is thrown")
|
||||||
{ "limit", { "5" } }
|
AND_THEN ("No errors are returned")
|
||||||
});
|
AND_THEN ("Answer is valid")
|
||||||
if (ret.answer == "[]")
|
AND_THEN ("The answer makes sense")
|
||||||
{
|
{
|
||||||
WARN("No followed found.");
|
REQUIRE_FALSE(exception);
|
||||||
}
|
|
||||||
else
|
REQUIRE(ret.error_code == 0);
|
||||||
{
|
REQUIRE(ret.http_error_code == 200);
|
||||||
account.from_string
|
|
||||||
(Easy::json_array_to_vector(ret.answer).front());
|
REQUIRE(account.valid());
|
||||||
}
|
|
||||||
}
|
REQUIRE(account.username() != "");
|
||||||
catch (const std::exception &e)
|
|
||||||
{
|
|
||||||
exception = true;
|
|
||||||
WARN(e.what());
|
|
||||||
}
|
|
||||||
THEN("No exception is thrown")
|
|
||||||
{
|
|
||||||
REQUIRE_FALSE(exception);
|
|
||||||
}
|
|
||||||
THEN ("No errors are returned")
|
|
||||||
{
|
|
||||||
REQUIRE(ret.error_code == 0);
|
|
||||||
REQUIRE(ret.http_error_code == 200);
|
|
||||||
}
|
|
||||||
THEN ("Answer is valid")
|
|
||||||
{
|
|
||||||
REQUIRE(account.valid());
|
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE(account.username() != "");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,111 +27,61 @@ using namespace Mastodon;
|
||||||
SCENARIO ("/api/v1/accounts/:id/statuses can be called successfully",
|
SCENARIO ("/api/v1/accounts/:id/statuses can be called successfully",
|
||||||
"[api][mastodon][pleroma][glitch-soc]")
|
"[api][mastodon][pleroma][glitch-soc]")
|
||||||
{
|
{
|
||||||
GIVEN ("instance, access token, user id and return_call")
|
const char *env_instance = std::getenv("MASTODON_CPP_INSTANCE");
|
||||||
{
|
const string instance = (env_instance ? env_instance : "likeable.space");
|
||||||
const char *env_instance = std::getenv("MASTODON_CPP_INSTANCE");
|
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
||||||
const string instance =
|
const char *env_user_id = std::getenv("MASTODON_CPP_USER_ID");
|
||||||
(env_instance ? env_instance : "likeable.space");
|
const string user_id = (env_user_id ? env_user_id : "9hnrrVPriLiLVAhfVo");
|
||||||
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
|
||||||
const char *env_user_id = std::getenv("MASTODON_CPP_USER_ID");
|
|
||||||
const string user_id =
|
|
||||||
(env_user_id ? env_user_id : "9hnrrVPriLiLVAhfVo");
|
|
||||||
|
|
||||||
|
GIVEN ("instance = " + instance + ", user ID = " + user_id)
|
||||||
|
{
|
||||||
|
Mastodon::Easy::API masto(instance, access_token);
|
||||||
return_call ret;
|
return_call ret;
|
||||||
|
Easy::Status status;
|
||||||
bool exception = false;
|
bool exception = false;
|
||||||
bool content_found = false;
|
|
||||||
|
|
||||||
REQUIRE (access_token != nullptr);
|
REQUIRE (access_token != nullptr);
|
||||||
|
|
||||||
GIVEN ("Mastodon::API")
|
WHEN ("/api/v1/accounts/" + user_id + "/statuses is called")
|
||||||
{
|
{
|
||||||
Mastodon::API masto(instance, access_token);
|
try
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/" + user_id + "/statuses is called")
|
|
||||||
{
|
{
|
||||||
try
|
ret = masto.get(API::v1::accounts_id_statuses,
|
||||||
|
{
|
||||||
|
{ "id", { user_id } },
|
||||||
|
{ "limit", { "5" } }
|
||||||
|
});
|
||||||
|
if (ret.answer == "[]")
|
||||||
{
|
{
|
||||||
ret = masto.get(API::v1::accounts_id_statuses,
|
WARN("No statuses found.");
|
||||||
{
|
|
||||||
{ "id", { user_id } },
|
|
||||||
{ "limit", { "5" } }
|
|
||||||
});
|
|
||||||
if (ret.answer == "[]")
|
|
||||||
{
|
|
||||||
WARN("No statuses found.");
|
|
||||||
}
|
|
||||||
content_found =
|
|
||||||
ret.answer.find("\"content\":\"")
|
|
||||||
!= std::string::npos;
|
|
||||||
}
|
}
|
||||||
catch (const std::exception &e)
|
else
|
||||||
{
|
{
|
||||||
exception = true;
|
status.from_string
|
||||||
WARN(e.what());
|
(Easy::json_array_to_vector(ret.answer).front());
|
||||||
}
|
|
||||||
THEN("No exception is thrown")
|
|
||||||
{
|
|
||||||
REQUIRE_FALSE(exception);
|
|
||||||
}
|
|
||||||
THEN ("No errors are returned")
|
|
||||||
{
|
|
||||||
REQUIRE(ret.error_code == 0);
|
|
||||||
REQUIRE(ret.http_error_code == 200);
|
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE(content_found);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
catch (const std::exception &e)
|
||||||
|
|
||||||
GIVEN ("Mastodon::Easy::API")
|
|
||||||
{
|
|
||||||
Mastodon::Easy::API masto(instance, access_token);
|
|
||||||
Easy::Status status;
|
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/" + user_id + "/statuses is called")
|
|
||||||
{
|
{
|
||||||
try
|
exception = true;
|
||||||
{
|
WARN(e.what());
|
||||||
ret = masto.get(API::v1::accounts_id_statuses,
|
}
|
||||||
{
|
|
||||||
{ "id", { user_id } },
|
THEN("No exception is thrown")
|
||||||
{ "limit", { "5" } }
|
AND_THEN ("No errors are returned")
|
||||||
});
|
AND_THEN ("Answer is valid")
|
||||||
if (ret.answer == "[]")
|
AND_THEN ("The answer makes sense")
|
||||||
{
|
{
|
||||||
WARN("No statuses found.");
|
REQUIRE_FALSE(exception);
|
||||||
}
|
|
||||||
else
|
REQUIRE(ret.error_code == 0);
|
||||||
{
|
REQUIRE(ret.http_error_code == 200);
|
||||||
status.from_string
|
|
||||||
(Easy::json_array_to_vector(ret.answer).front());
|
REQUIRE(status.valid());
|
||||||
}
|
|
||||||
}
|
REQUIRE(status.content() != "");
|
||||||
catch (const std::exception &e)
|
|
||||||
{
|
|
||||||
exception = true;
|
|
||||||
WARN(e.what());
|
|
||||||
}
|
|
||||||
THEN("No exception is thrown")
|
|
||||||
{
|
|
||||||
REQUIRE_FALSE(exception);
|
|
||||||
}
|
|
||||||
THEN ("No errors are returned")
|
|
||||||
{
|
|
||||||
REQUIRE(ret.error_code == 0);
|
|
||||||
REQUIRE(ret.http_error_code == 200);
|
|
||||||
}
|
|
||||||
THEN ("Answer is valid")
|
|
||||||
{
|
|
||||||
REQUIRE(status.valid());
|
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE(status.content() != "");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,103 +27,50 @@ using namespace Mastodon;
|
||||||
SCENARIO ("/api/v1/accounts/:id/unfollow can be called successfully",
|
SCENARIO ("/api/v1/accounts/:id/unfollow can be called successfully",
|
||||||
"[api][mastodon][pleroma][glitch-soc]")
|
"[api][mastodon][pleroma][glitch-soc]")
|
||||||
{
|
{
|
||||||
GIVEN ("instance, access token, user id and return_call")
|
const char *env_instance = std::getenv("MASTODON_CPP_INSTANCE");
|
||||||
|
const string instance = (env_instance ? env_instance : "likeable.space");
|
||||||
|
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
||||||
|
const char *env_user_id = std::getenv("MASTODON_CPP_USER_ID");
|
||||||
|
const string user_id = (env_user_id ? env_user_id : "9hnrrVPriLiLVAhfVo");
|
||||||
|
|
||||||
|
GIVEN ("instance = " + instance + ", user ID = " + user_id)
|
||||||
{
|
{
|
||||||
const char *env_instance = std::getenv("MASTODON_CPP_INSTANCE");
|
Mastodon::Easy::API masto(instance, access_token);
|
||||||
const string instance =
|
|
||||||
(env_instance ? env_instance : "likeable.space");
|
|
||||||
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
|
||||||
const char *env_user_id = std::getenv("MASTODON_CPP_USER_ID");
|
|
||||||
const string user_id =
|
|
||||||
(env_user_id ? env_user_id : "9hnrrVPriLiLVAhfVo");
|
|
||||||
|
|
||||||
return_call ret;
|
return_call ret;
|
||||||
|
Easy::Relationship relationship;
|
||||||
bool exception = false;
|
bool exception = false;
|
||||||
bool following_found = true;
|
|
||||||
bool error_found = false;
|
|
||||||
|
|
||||||
// You can't unfollow yourself, so we look for errors too.
|
|
||||||
|
|
||||||
REQUIRE (access_token != nullptr);
|
REQUIRE (access_token != nullptr);
|
||||||
|
|
||||||
GIVEN ("Mastodon::API")
|
WHEN ("/api/v1/accounts/" + user_id + "/unfollow is called")
|
||||||
{
|
{
|
||||||
Mastodon::API masto(instance, access_token);
|
try
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/" + user_id + "/unfollow is called")
|
|
||||||
{
|
{
|
||||||
try
|
ret = masto.post(API::v1::accounts_id_unfollow,
|
||||||
{
|
{
|
||||||
ret = masto.post(API::v1::accounts_id_unfollow,
|
{ "id", { user_id } },
|
||||||
{
|
});
|
||||||
{ "id", { user_id } },
|
relationship.from_string(ret.answer);
|
||||||
});
|
|
||||||
following_found =
|
|
||||||
ret.answer.find("\"following\":\"")
|
|
||||||
!= std::string::npos;
|
|
||||||
error_found = following_found =
|
|
||||||
ret.answer.find("\"error")
|
|
||||||
!= std::string::npos;
|
|
||||||
}
|
|
||||||
catch (const std::exception &e)
|
|
||||||
{
|
|
||||||
exception = true;
|
|
||||||
WARN(e.what());
|
|
||||||
}
|
|
||||||
THEN("No exception is thrown")
|
|
||||||
{
|
|
||||||
REQUIRE_FALSE(exception);
|
|
||||||
}
|
|
||||||
THEN ("No unexpected errors are returned")
|
|
||||||
{
|
|
||||||
REQUIRE((ret.error_code == 0
|
|
||||||
|| ret.error_code == 111));
|
|
||||||
REQUIRE((ret.http_error_code == 200
|
|
||||||
|| ret.http_error_code == 500));
|
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE((!following_found || error_found));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
catch (const std::exception &e)
|
||||||
|
|
||||||
GIVEN ("Mastodon::Easy::API")
|
|
||||||
{
|
|
||||||
Mastodon::Easy::API masto(instance, access_token);
|
|
||||||
Easy::Relationship relationship;
|
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/" + user_id + "/unfollow is called")
|
|
||||||
{
|
{
|
||||||
try
|
exception = true;
|
||||||
{
|
WARN(e.what());
|
||||||
ret = masto.post(API::v1::accounts_id_unfollow,
|
}
|
||||||
{
|
THEN("No exception is thrown")
|
||||||
{ "id", { user_id } },
|
AND_THEN ("No unexpected errors are returned")
|
||||||
});
|
AND_THEN ("The answer makes sense")
|
||||||
relationship.from_string(ret.answer);
|
{
|
||||||
}
|
REQUIRE_FALSE(exception);
|
||||||
catch (const std::exception &e)
|
|
||||||
{
|
// You can't unfollow yourself, so we look for errors too.
|
||||||
exception = true;
|
REQUIRE((ret.error_code == 0
|
||||||
WARN(e.what());
|
|| ret.error_code == 111));
|
||||||
}
|
REQUIRE((ret.http_error_code == 200
|
||||||
THEN("No exception is thrown")
|
|| ret.http_error_code == 500));
|
||||||
{
|
|
||||||
REQUIRE_FALSE(exception);
|
REQUIRE((!relationship.following()
|
||||||
}
|
|| relationship.error() != ""));
|
||||||
THEN ("No unexpected errors are returned")
|
|
||||||
{
|
|
||||||
REQUIRE((ret.error_code == 0
|
|
||||||
|| ret.error_code == 111));
|
|
||||||
REQUIRE((ret.http_error_code == 200
|
|
||||||
|| ret.http_error_code == 500));
|
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE((!relationship.following()
|
|
||||||
|| relationship.error() != ""));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,108 +27,58 @@ using namespace Mastodon;
|
||||||
SCENARIO ("/api/v1/accounts/relationships can be called successfully",
|
SCENARIO ("/api/v1/accounts/relationships can be called successfully",
|
||||||
"[api][mastodon][pleroma][glitch-soc]")
|
"[api][mastodon][pleroma][glitch-soc]")
|
||||||
{
|
{
|
||||||
GIVEN ("instance, access token, user id and return_call")
|
const char *env_instance = std::getenv("MASTODON_CPP_INSTANCE");
|
||||||
{
|
const string instance = (env_instance ? env_instance : "likeable.space");
|
||||||
const char *env_instance = std::getenv("MASTODON_CPP_INSTANCE");
|
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
||||||
const string instance =
|
const char *env_user_id = std::getenv("MASTODON_CPP_USER_ID");
|
||||||
(env_instance ? env_instance : "likeable.space");
|
const string user_id = (env_user_id ? env_user_id : "9hnrrVPriLiLVAhfVo");
|
||||||
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
|
||||||
const char *env_user_id = std::getenv("MASTODON_CPP_USER_ID");
|
|
||||||
const string user_id =
|
|
||||||
(env_user_id ? env_user_id : "9hnrrVPriLiLVAhfVo");
|
|
||||||
|
|
||||||
|
GIVEN ("instance = " + instance + ", user ID = " + user_id)
|
||||||
|
{
|
||||||
|
Mastodon::Easy::API masto(instance, access_token);
|
||||||
return_call ret;
|
return_call ret;
|
||||||
|
Easy::Relationship relationship;
|
||||||
bool exception = false;
|
bool exception = false;
|
||||||
bool id_found = false;
|
|
||||||
|
|
||||||
REQUIRE (access_token != nullptr);
|
REQUIRE (access_token != nullptr);
|
||||||
|
|
||||||
GIVEN ("Mastodon::API")
|
WHEN ("/api/v1/accounts/relationships is called")
|
||||||
{
|
{
|
||||||
Mastodon::API masto(instance, access_token);
|
try
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/relationships is called")
|
|
||||||
{
|
{
|
||||||
try
|
ret = masto.get(API::v1::accounts_relationships,
|
||||||
|
{
|
||||||
|
{ "id", { user_id } },
|
||||||
|
});
|
||||||
|
if (ret.answer == "[]")
|
||||||
{
|
{
|
||||||
ret = masto.get(API::v1::accounts_relationships,
|
WARN("No relationships found.");
|
||||||
{
|
|
||||||
{ "id", { user_id } },
|
|
||||||
});
|
|
||||||
if (ret.answer == "[]")
|
|
||||||
{
|
|
||||||
WARN("No relationships found.");
|
|
||||||
}
|
|
||||||
id_found =
|
|
||||||
ret.answer.find("\"id\":\"")
|
|
||||||
!= std::string::npos;
|
|
||||||
}
|
}
|
||||||
catch (const std::exception &e)
|
else
|
||||||
{
|
{
|
||||||
exception = true;
|
relationship.from_string
|
||||||
WARN(e.what());
|
(Easy::json_array_to_vector(ret.answer).front());
|
||||||
}
|
|
||||||
THEN("No exception is thrown")
|
|
||||||
{
|
|
||||||
REQUIRE_FALSE(exception);
|
|
||||||
}
|
|
||||||
THEN ("No errors are returned")
|
|
||||||
{
|
|
||||||
REQUIRE(ret.error_code == 0);
|
|
||||||
REQUIRE(ret.http_error_code == 200);
|
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE(id_found);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
catch (const std::exception &e)
|
||||||
|
|
||||||
GIVEN ("Mastodon::Easy::API")
|
|
||||||
{
|
|
||||||
Mastodon::Easy::API masto(instance, access_token);
|
|
||||||
Easy::Relationship relationship;
|
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/relationships is called")
|
|
||||||
{
|
{
|
||||||
try
|
exception = true;
|
||||||
{
|
WARN(e.what());
|
||||||
ret = masto.get(API::v1::accounts_relationships,
|
}
|
||||||
{
|
|
||||||
{ "id", { user_id } },
|
THEN("No exception is thrown")
|
||||||
});
|
AND_THEN ("No errors are returned")
|
||||||
if (ret.answer == "[]")
|
AND_THEN ("Answer is valid")
|
||||||
{
|
AND_THEN ("The answer makes sense")
|
||||||
WARN("No relationships found.");
|
{
|
||||||
}
|
REQUIRE_FALSE(exception);
|
||||||
else
|
|
||||||
{
|
REQUIRE(ret.error_code == 0);
|
||||||
relationship.from_string
|
REQUIRE(ret.http_error_code == 200);
|
||||||
(Easy::json_array_to_vector(ret.answer).front());
|
|
||||||
}
|
REQUIRE(relationship.valid());
|
||||||
}
|
|
||||||
catch (const std::exception &e)
|
REQUIRE(relationship.id() != "");
|
||||||
{
|
|
||||||
exception = true;
|
|
||||||
WARN(e.what());
|
|
||||||
}
|
|
||||||
THEN("No exception is thrown")
|
|
||||||
{
|
|
||||||
REQUIRE_FALSE(exception);
|
|
||||||
}
|
|
||||||
THEN ("No errors are returned")
|
|
||||||
{
|
|
||||||
REQUIRE(ret.error_code == 0);
|
|
||||||
REQUIRE(ret.http_error_code == 200);
|
|
||||||
}
|
|
||||||
THEN ("Answer is valid")
|
|
||||||
{
|
|
||||||
REQUIRE(relationship.valid());
|
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE(relationship.id() != "");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,87 +27,48 @@ using namespace Mastodon;
|
||||||
SCENARIO ("/api/v1/accounts/update_credentials can be called successfully",
|
SCENARIO ("/api/v1/accounts/update_credentials can be called successfully",
|
||||||
"[api][mastodon][pleroma][glitch-soc]")
|
"[api][mastodon][pleroma][glitch-soc]")
|
||||||
{
|
{
|
||||||
GIVEN ("instance, access token and return_call")
|
const char *envinstance = std::getenv("MASTODON_CPP_INSTANCE");
|
||||||
|
const string instance = (envinstance ? envinstance : "likeable.space");
|
||||||
|
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
||||||
|
const char *env_user_id = std::getenv("MASTODON_CPP_USER_ID");
|
||||||
|
const string user_id = (env_user_id ? env_user_id : "9hnrrVPriLiLVAhfVo");
|
||||||
|
|
||||||
|
GIVEN ("instance = " + instance + ", user ID = " + user_id)
|
||||||
{
|
{
|
||||||
const char *envinstance = std::getenv("MASTODON_CPP_INSTANCE");
|
Mastodon::Easy::API masto(instance, access_token);
|
||||||
const string instance = (envinstance ? envinstance : "likeable.space");
|
|
||||||
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
|
||||||
return_call ret;
|
return_call ret;
|
||||||
|
Easy::Account account;
|
||||||
bool exception = false;
|
bool exception = false;
|
||||||
bool display_name_found = false;
|
|
||||||
|
|
||||||
REQUIRE (access_token != nullptr);
|
REQUIRE (access_token != nullptr);
|
||||||
|
|
||||||
GIVEN ("Mastodon::API")
|
WHEN ("/api/v1/accounts/update_credentials is called")
|
||||||
{
|
{
|
||||||
Mastodon::API masto(instance, access_token);
|
try
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/update_credentials is called")
|
|
||||||
{
|
{
|
||||||
try
|
ret = masto.patch(API::v1::accounts_update_credentials,
|
||||||
{
|
{{ "display_name", { "testaccount" } }});
|
||||||
ret = masto.patch(API::v1::accounts_update_credentials,
|
account = Easy::Account(ret.answer);
|
||||||
{{ "display_name", { "testaccount" } }});
|
|
||||||
display_name_found =
|
|
||||||
ret.answer.find("\"display_name\":\"testaccount\"")
|
|
||||||
!= std::string::npos;
|
|
||||||
}
|
|
||||||
catch (const std::exception &e)
|
|
||||||
{
|
|
||||||
exception = true;
|
|
||||||
WARN(e.what());
|
|
||||||
}
|
|
||||||
THEN("No exception is thrown")
|
|
||||||
{
|
|
||||||
REQUIRE_FALSE(exception);
|
|
||||||
}
|
|
||||||
THEN ("No errors are returned")
|
|
||||||
{
|
|
||||||
REQUIRE(ret.error_code == 0);
|
|
||||||
REQUIRE(ret.http_error_code == 200);
|
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE(display_name_found);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
catch (const std::exception &e)
|
||||||
|
|
||||||
GIVEN ("Mastodon::Easy::API")
|
|
||||||
{
|
|
||||||
Mastodon::Easy::API masto(instance, access_token);
|
|
||||||
Easy::Account account;
|
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/update_credentials is called")
|
|
||||||
{
|
{
|
||||||
try
|
exception = true;
|
||||||
{
|
WARN(e.what());
|
||||||
ret = masto.patch(API::v1::accounts_update_credentials,
|
}
|
||||||
{{ "display_name", { "testaccount" } }});
|
|
||||||
account = Easy::Account(ret.answer);
|
THEN("No exception is thrown")
|
||||||
}
|
AND_THEN ("No errors are returned")
|
||||||
catch (const std::exception &e)
|
AND_THEN ("Answer is valid")
|
||||||
{
|
AND_THEN ("The answer makes sense")
|
||||||
exception = true;
|
{
|
||||||
WARN(e.what());
|
REQUIRE_FALSE(exception);
|
||||||
}
|
|
||||||
THEN("No exception is thrown")
|
REQUIRE(ret.error_code == 0);
|
||||||
{
|
REQUIRE(ret.http_error_code == 200);
|
||||||
REQUIRE_FALSE(exception);
|
|
||||||
}
|
REQUIRE(account.valid());
|
||||||
THEN ("No errors are returned")
|
|
||||||
{
|
REQUIRE(account.id() == user_id);
|
||||||
REQUIRE(ret.error_code == 0);
|
|
||||||
REQUIRE(ret.http_error_code == 200);
|
|
||||||
}
|
|
||||||
THEN ("Answer is valid")
|
|
||||||
{
|
|
||||||
REQUIRE(account.valid());
|
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE(account.display_name() == "testaccount");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,85 +27,49 @@ using namespace Mastodon;
|
||||||
SCENARIO ("/api/v1/accounts/verify_credentials can be called successfully",
|
SCENARIO ("/api/v1/accounts/verify_credentials can be called successfully",
|
||||||
"[api][mastodon][pleroma][glitch-soc]")
|
"[api][mastodon][pleroma][glitch-soc]")
|
||||||
{
|
{
|
||||||
GIVEN ("instance, access token and return_call")
|
const char *envinstance = std::getenv("MASTODON_CPP_INSTANCE");
|
||||||
|
const string instance = (envinstance ? envinstance : "likeable.space");
|
||||||
|
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
||||||
|
const char *env_user_id = std::getenv("MASTODON_CPP_USER_ID");
|
||||||
|
const string user_id = (env_user_id ? env_user_id : "9hnrrVPriLiLVAhfVo");
|
||||||
|
|
||||||
|
GIVEN ("instance = " + instance + ", user ID = " + user_id)
|
||||||
{
|
{
|
||||||
const char *envinstance = std::getenv("MASTODON_CPP_INSTANCE");
|
Mastodon::Easy::API masto(instance, access_token);
|
||||||
const string instance = (envinstance ? envinstance : "likeable.space");
|
|
||||||
const char *access_token = std::getenv("MASTODON_CPP_ACCESS_TOKEN");
|
|
||||||
return_call ret;
|
return_call ret;
|
||||||
|
Easy::Account account;
|
||||||
bool exception = false;
|
bool exception = false;
|
||||||
bool username_found = false;
|
|
||||||
|
|
||||||
REQUIRE (access_token != nullptr);
|
REQUIRE (access_token != nullptr);
|
||||||
|
|
||||||
GIVEN ("Mastodon::API")
|
WHEN ("/api/v1/accounts/verify_credentials is called")
|
||||||
{
|
{
|
||||||
Mastodon::API masto(instance, access_token);
|
try
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/verify_credentials is called")
|
|
||||||
{
|
{
|
||||||
try
|
ret = masto.get(API::v1::accounts_verify_credentials);
|
||||||
{
|
account = Easy::Account(ret.answer);
|
||||||
ret = masto.get(API::v1::accounts_verify_credentials);
|
|
||||||
username_found = ret.answer.find(
|
|
||||||
"\"username\":\"testaccount\"") != std::string::npos;
|
|
||||||
}
|
|
||||||
catch (const std::exception &e)
|
|
||||||
{
|
|
||||||
exception = true;
|
|
||||||
WARN(e.what());
|
|
||||||
}
|
|
||||||
THEN("No exception is thrown")
|
|
||||||
{
|
|
||||||
REQUIRE_FALSE(exception);
|
|
||||||
}
|
|
||||||
THEN ("No errors are returned")
|
|
||||||
{
|
|
||||||
REQUIRE(ret.error_code == 0);
|
|
||||||
REQUIRE(ret.http_error_code == 200);
|
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE(username_found);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
catch (const std::exception &e)
|
||||||
|
|
||||||
GIVEN ("Mastodon::Easy::API")
|
|
||||||
{
|
|
||||||
Mastodon::Easy::API masto(instance, access_token);
|
|
||||||
Easy::Account account;
|
|
||||||
|
|
||||||
WHEN ("/api/v1/accounts/verify_credentials is called")
|
|
||||||
{
|
{
|
||||||
try
|
exception = true;
|
||||||
{
|
WARN(e.what());
|
||||||
ret = masto.get(API::v1::accounts_verify_credentials);
|
}
|
||||||
account = Easy::Account(ret.answer);
|
|
||||||
}
|
THEN("No exception is thrown")
|
||||||
catch (const std::exception &e)
|
AND_THEN ("No errors are returned")
|
||||||
{
|
AND_THEN ("Answer is valid")
|
||||||
exception = true;
|
AND_THEN ("The answer makes sense")
|
||||||
WARN(e.what());
|
{
|
||||||
}
|
REQUIRE_FALSE(exception);
|
||||||
THEN("No exception is thrown")
|
|
||||||
{
|
REQUIRE(ret.error_code == 0);
|
||||||
REQUIRE_FALSE(exception);
|
REQUIRE(ret.http_error_code == 200);
|
||||||
}
|
|
||||||
THEN ("No errors are returned")
|
REQUIRE(account.valid());
|
||||||
{
|
|
||||||
REQUIRE(ret.error_code == 0);
|
REQUIRE(account.id() == user_id);
|
||||||
REQUIRE(ret.http_error_code == 200);
|
|
||||||
}
|
|
||||||
THEN ("Answer is valid")
|
|
||||||
{
|
|
||||||
REQUIRE(account.valid());
|
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE(account.username() == "testaccount");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,83 +26,43 @@ using namespace Mastodon;
|
||||||
SCENARIO ("/api/v1/instance can be called successfully",
|
SCENARIO ("/api/v1/instance can be called successfully",
|
||||||
"[api][mastodon][pleroma][glitch-soc]")
|
"[api][mastodon][pleroma][glitch-soc]")
|
||||||
{
|
{
|
||||||
GIVEN ("instance and return_call")
|
const char *envinstance = std::getenv("MASTODON_CPP_INSTANCE");
|
||||||
|
const string instance = (envinstance ? envinstance : "likeable.space");
|
||||||
|
GIVEN ("instance = " + instance)
|
||||||
{
|
{
|
||||||
const char *envinstance = std::getenv("MASTODON_CPP_INSTANCE");
|
Mastodon::Easy::API masto(instance, "");
|
||||||
const string instance = (envinstance ? envinstance : "likeable.space");
|
|
||||||
return_call ret;
|
return_call ret;
|
||||||
|
Easy::Instance instance_;
|
||||||
bool exception = false;
|
bool exception = false;
|
||||||
|
|
||||||
GIVEN ("Mastodon::API")
|
WHEN ("/api/v1/instance is called")
|
||||||
{
|
{
|
||||||
Mastodon::API masto(instance, "");
|
try
|
||||||
bool uri_found = false;
|
|
||||||
|
|
||||||
WHEN ("/api/v1/instance is called")
|
|
||||||
{
|
{
|
||||||
try
|
ret = masto.get(API::v1::instance);
|
||||||
{
|
instance_ = Easy::Instance(ret.answer);
|
||||||
ret = masto.get(API::v1::instance);
|
|
||||||
uri_found =
|
|
||||||
ret.answer.find("\"uri\":\"https://likeable.space\"")
|
|
||||||
!= std::string::npos;
|
|
||||||
}
|
|
||||||
catch (const std::exception &e)
|
|
||||||
{
|
|
||||||
exception = true;
|
|
||||||
WARN(e.what());
|
|
||||||
}
|
|
||||||
THEN("No exception is thrown")
|
|
||||||
{
|
|
||||||
REQUIRE_FALSE(exception);
|
|
||||||
}
|
|
||||||
THEN ("No errors are returned")
|
|
||||||
{
|
|
||||||
REQUIRE(ret.error_code == 0);
|
|
||||||
REQUIRE(ret.http_error_code == 200);
|
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE(uri_found);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
catch (const std::exception &e)
|
||||||
|
|
||||||
GIVEN ("Mastodon::Easy::API")
|
|
||||||
{
|
|
||||||
Mastodon::Easy::API masto(instance, "");
|
|
||||||
Easy::Instance instance_;
|
|
||||||
|
|
||||||
WHEN ("/api/v1/instance is called")
|
|
||||||
{
|
{
|
||||||
try
|
exception = true;
|
||||||
{
|
WARN(e.what());
|
||||||
ret = masto.get(API::v1::instance);
|
}
|
||||||
instance_ = Easy::Instance(ret.answer);
|
|
||||||
}
|
THEN("No exception is thrown")
|
||||||
catch (const std::exception &e)
|
AND_THEN ("No errors are returned")
|
||||||
{
|
AND_THEN ("Answer is valid")
|
||||||
exception = true;
|
AND_THEN ("The answer makes sense")
|
||||||
WARN(e.what());
|
{
|
||||||
}
|
REQUIRE_FALSE(exception);
|
||||||
THEN("No exception is thrown")
|
|
||||||
{
|
REQUIRE(ret.error_code == 0);
|
||||||
REQUIRE_FALSE(exception);
|
REQUIRE(ret.http_error_code == 200);
|
||||||
}
|
|
||||||
THEN ("No errors are returned")
|
REQUIRE(instance_.valid());
|
||||||
{
|
|
||||||
REQUIRE(ret.error_code == 0);
|
REQUIRE(instance_.uri() == ("https://" + instance));
|
||||||
REQUIRE(ret.http_error_code == 200);
|
|
||||||
}
|
|
||||||
THEN ("Answer is valid")
|
|
||||||
{
|
|
||||||
REQUIRE(instance_.valid());
|
|
||||||
}
|
|
||||||
THEN ("The answer makes sense")
|
|
||||||
{
|
|
||||||
REQUIRE(instance_.uri() == "https://likeable.space");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
SCENARIO ("Instantiating API classes works")
|
SCENARIO ("Instantiating API classes works")
|
||||||
{
|
{
|
||||||
bool exception = false;
|
bool exception = false;
|
||||||
|
|
||||||
WHEN ("Mastodon::API")
|
WHEN ("Mastodon::API")
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -32,6 +33,7 @@ SCENARIO ("Instantiating API classes works")
|
||||||
{
|
{
|
||||||
exception = true;
|
exception = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
THEN ("No exception is thrown")
|
THEN ("No exception is thrown")
|
||||||
{
|
{
|
||||||
REQUIRE_FALSE(exception);
|
REQUIRE_FALSE(exception);
|
||||||
|
@ -48,6 +50,7 @@ SCENARIO ("Instantiating API classes works")
|
||||||
{
|
{
|
||||||
exception = true;
|
exception = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
THEN ("No exception is thrown")
|
THEN ("No exception is thrown")
|
||||||
{
|
{
|
||||||
REQUIRE_FALSE(exception);
|
REQUIRE_FALSE(exception);
|
||||||
|
|
Reference in New Issue