diff options
author | Neil Johnson <neil@matrix.org> | 2018-08-08 12:44:15 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-08 12:44:15 +0000 |
commit | 990fe9fc23245d193233b88f924e905ee4b2de3d (patch) | |
tree | bc5aed8a97fdd22845ec48e5c84fea981f812003 /tests/api | |
parent | Merge pull request #3658 from matrix-org/rav/fix_event_persisted_position_met... (diff) | |
parent | typos (diff) | |
download | synapse-990fe9fc23245d193233b88f924e905ee4b2de3d.tar.xz |
Merge pull request #3633 from matrix-org/neilj/mau_tracker
API for monthly_active_users table
Diffstat (limited to 'tests/api')
-rw-r--r-- | tests/api/test_auth.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/api/test_auth.py b/tests/api/test_auth.py index a82d737e71..5dc3398300 100644 --- a/tests/api/test_auth.py +++ b/tests/api/test_auth.py @@ -444,3 +444,28 @@ class AuthTestCase(unittest.TestCase): self.assertEqual("Guest access token used for regular user", cm.exception.msg) self.store.get_user_by_id.assert_called_with(USER_ID) + + @defer.inlineCallbacks + def test_blocking_mau(self): + self.hs.config.limit_usage_by_mau = False + self.hs.config.max_mau_value = 50 + lots_of_users = 100 + small_number_of_users = 1 + + # Ensure no error thrown + yield self.auth.check_auth_blocking() + + self.hs.config.limit_usage_by_mau = True + + self.store.get_monthly_active_count = Mock( + return_value=defer.succeed(lots_of_users) + ) + + with self.assertRaises(AuthError): + yield self.auth.check_auth_blocking() + + # Ensure does not throw an error + self.store.get_monthly_active_count = Mock( + return_value=defer.succeed(small_number_of_users) + ) + yield self.auth.check_auth_blocking() |