summary refs log tree commit diff
path: root/tests/storage
diff options
context:
space:
mode:
authorTravis Ralston <travpc@gmail.com>2018-11-15 11:08:27 -0700
committerRichard van der Hoff <1389908+richvdh@users.noreply.github.com>2018-11-15 18:08:27 +0000
commit835779f7fb8e8b84c3f8e371528d6ea08d0c373f (patch)
treee45ac0bbcae1750ce3adff184c6fae733e9a38f3 /tests/storage
parentUse <meta> tags to discover the per-page encoding of html previews (#4183) (diff)
downloadsynapse-835779f7fb8e8b84c3f8e371528d6ea08d0c373f.tar.xz
Add option to track MAU stats (but not limit people) (#3830)
Diffstat (limited to 'tests/storage')
-rw-r--r--tests/storage/test_monthly_active_users.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/storage/test_monthly_active_users.py b/tests/storage/test_monthly_active_users.py
index 832e379a83..8664bc3d54 100644
--- a/tests/storage/test_monthly_active_users.py
+++ b/tests/storage/test_monthly_active_users.py
@@ -220,3 +220,28 @@ class MonthlyActiveUsersTestCase(HomeserverTestCase):
         self.store.user_add_threepid(user2, "email", user2_email, now, now)
         count = self.store.get_registered_reserved_users_count()
         self.assertEquals(self.get_success(count), len(threepids))
+
+    def test_track_monthly_users_without_cap(self):
+        self.hs.config.limit_usage_by_mau = False
+        self.hs.config.mau_stats_only = True
+        self.hs.config.max_mau_value = 1  # should not matter
+
+        count = self.store.get_monthly_active_count()
+        self.assertEqual(0, self.get_success(count))
+
+        self.store.upsert_monthly_active_user("@user1:server")
+        self.store.upsert_monthly_active_user("@user2:server")
+        self.pump()
+
+        count = self.store.get_monthly_active_count()
+        self.assertEqual(2, self.get_success(count))
+
+    def test_no_users_when_not_tracking(self):
+        self.hs.config.limit_usage_by_mau = False
+        self.hs.config.mau_stats_only = False
+        self.store.upsert_monthly_active_user = Mock()
+
+        self.store.populate_monthly_active_users("@user:sever")
+        self.pump()
+
+        self.store.upsert_monthly_active_user.assert_not_called()