1
0

fix tests

This commit is contained in:
Matthew Hodgson
2018-08-22 19:13:06 +02:00
parent 3a46874407
commit f12bb11797
6 changed files with 11 additions and 2 deletions

View File

@@ -145,10 +145,10 @@ class MonthlyActiveUsersStore(SQLBaseStore):
sql = """
SELECT COALESCE(count(*), 0)
FROM monthly_active_users
WHERE timestamp - last_active > ?
WHERE timestamp - first_active >= ?
"""
txn.execute(sql, mau_trial_ms)
txn.execute(sql, (mau_trial_ms,))
count, = txn.fetchone()
return count
return self.runInteraction("count_users", _count_users)

View File

@@ -41,6 +41,7 @@ class AuthTestCase(unittest.TestCase):
self.macaroon_generator = self.hs.get_macaroon_generator()
# MAU tests
self.hs.config.max_mau_value = 50
self.hs.config.mau_trial_days = 0
self.small_number_of_users = 1
self.large_number_of_users = 100

View File

@@ -54,6 +54,7 @@ class RegistrationTestCase(unittest.TestCase):
self.handler = self.hs.get_handlers().registration_handler
self.store = self.hs.get_datastore()
self.hs.config.max_mau_value = 50
self.hs.config.mau_trial_days = 0
self.lots_of_users = 100
self.small_number_of_users = 1

View File

@@ -42,6 +42,7 @@ class SyncTestCase(tests.unittest.TestCase):
self.hs.config.limit_usage_by_mau = True
self.hs.config.max_mau_value = 1
self.hs.config.mau_trial_days = 0
# Check that the happy case does not throw errors
yield self.store.upsert_monthly_active_user(user_id1)

View File

@@ -59,6 +59,7 @@ class ClientIpStoreTestCase(tests.unittest.TestCase):
def test_disabled_monthly_active_user(self):
self.hs.config.limit_usage_by_mau = False
self.hs.config.max_mau_value = 50
self.hs.config.mau_trial_days = 0
user_id = "@user:server"
yield self.store.insert_client_ip(
user_id, "access_token", "ip", "user_agent", "device_id"
@@ -70,6 +71,7 @@ class ClientIpStoreTestCase(tests.unittest.TestCase):
def test_adding_monthly_active_user_when_full(self):
self.hs.config.limit_usage_by_mau = True
self.hs.config.max_mau_value = 50
self.hs.config.mau_trial_days = 0
lots_of_users = 100
user_id = "@user:server"
@@ -86,6 +88,7 @@ class ClientIpStoreTestCase(tests.unittest.TestCase):
def test_adding_monthly_active_user_when_space(self):
self.hs.config.limit_usage_by_mau = True
self.hs.config.max_mau_value = 50
self.hs.config.mau_trial_days = 0
user_id = "@user:server"
active = yield self.store.user_last_seen_monthly_active(user_id)
self.assertFalse(active)
@@ -100,6 +103,7 @@ class ClientIpStoreTestCase(tests.unittest.TestCase):
def test_updating_monthly_active_user_when_space(self):
self.hs.config.limit_usage_by_mau = True
self.hs.config.max_mau_value = 50
self.hs.config.mau_trial_days = 0
user_id = "@user:server"
active = yield self.store.user_last_seen_monthly_active(user_id)

View File

@@ -30,6 +30,8 @@ class MonthlyActiveUsersTestCase(tests.unittest.TestCase):
def setUp(self):
self.hs = yield setup_test_homeserver(self.addCleanup)
self.store = self.hs.get_datastore()
self.hs.config.max_mau_value = 2
self.hs.config.mau_trial_days = 0
@defer.inlineCallbacks
def test_initialise_reserved_users(self):