summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorfeld <feld@feld.me>2019-12-20 16:30:26 +0000
committerfeld <feld@feld.me>2019-12-20 16:30:26 +0000
commita54aa5af43bad062e7ab5ce946fa5add2fc4d48e (patch)
tree2b7c6fe32b9255e042a898544b66ab884797e999 /test
parent60819fd973b811b4e079cdb31c2764e92753f4af (diff)
parent5fc84552d311efd606f66775c55862b3d11ad258 (diff)
downloadpleroma-a54aa5af43bad062e7ab5ce946fa5add2fc4d48e.tar.gz
pleroma-a54aa5af43bad062e7ab5ce946fa5add2fc4d48e.zip
Merge branch 'feature/status-counts-by-scope' into 'develop'
Stats: return status counts by scope See merge request pleroma/pleroma!2076
Diffstat (limited to 'test')
-rw-r--r--test/stats_test.exs53
-rw-r--r--test/web/mastodon_api/controllers/instance_controller_test.exs10
2 files changed, 62 insertions, 1 deletions
diff --git a/test/stats_test.exs b/test/stats_test.exs
new file mode 100644
index 000000000..02a92dc64
--- /dev/null
+++ b/test/stats_test.exs
@@ -0,0 +1,53 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.StatsTest do
+ use Pleroma.DataCase
+
+ import Pleroma.Factory
+
+ alias Pleroma.Web.CommonAPI
+
+ describe "statuses count" do
+ setup do
+ user = insert(:user)
+ other_user = insert(:user)
+
+ CommonAPI.post(user, %{"visibility" => "public", "status" => "hey"})
+
+ Enum.each(0..1, fn _ ->
+ CommonAPI.post(user, %{
+ "visibility" => "unlisted",
+ "status" => "hey"
+ })
+ end)
+
+ Enum.each(0..2, fn _ ->
+ CommonAPI.post(user, %{
+ "visibility" => "direct",
+ "status" => "hey @#{other_user.nickname}"
+ })
+ end)
+
+ Enum.each(0..3, fn _ ->
+ CommonAPI.post(user, %{
+ "visibility" => "private",
+ "status" => "hey"
+ })
+ end)
+
+ :ok
+ end
+
+ test "it returns total number of statuses" do
+ data = Pleroma.Stats.get_stat_data()
+
+ assert data.stats.status_count.all == 10
+ assert data.stats.status_count.public == 1
+ assert data.stats.status_count.unlisted == 2
+ assert data.stats.status_count.direct == 3
+ assert data.stats.status_count.private == 4
+ end
+ end
+end
diff --git a/test/web/mastodon_api/controllers/instance_controller_test.exs b/test/web/mastodon_api/controllers/instance_controller_test.exs
index e00de6b18..7aa7c8648 100644
--- a/test/web/mastodon_api/controllers/instance_controller_test.exs
+++ b/test/web/mastodon_api/controllers/instance_controller_test.exs
@@ -58,7 +58,15 @@ defmodule Pleroma.Web.MastodonAPI.InstanceControllerTest do
assert stats
assert stats["user_count"] == 1
- assert stats["status_count"] == 1
+
+ assert stats["status_count"] == %{
+ "all" => 1,
+ "direct" => 0,
+ "private" => 0,
+ "public" => 1,
+ "unlisted" => 0
+ }
+
assert stats["domain_count"] == 2
end