|
@@ -13,23 +13,21 @@
|
|
|
# limitations under the License.
|
|
|
|
|
|
from synapse.api.constants import ReceiptTypes
|
|
|
-from synapse.replication.slave.storage.receipts import SlavedReceiptsStore
|
|
|
from synapse.types import UserID, create_requester
|
|
|
|
|
|
from tests.test_utils.event_injection import create_event
|
|
|
-
|
|
|
-from ._base import BaseSlavedStoreTestCase
|
|
|
+from tests.unittest import HomeserverTestCase
|
|
|
|
|
|
OTHER_USER_ID = "@other:test"
|
|
|
OUR_USER_ID = "@our:test"
|
|
|
|
|
|
|
|
|
-class SlavedReceiptTestCase(BaseSlavedStoreTestCase):
|
|
|
-
|
|
|
- STORE_TYPE = SlavedReceiptsStore
|
|
|
-
|
|
|
+class ReceiptTestCase(HomeserverTestCase):
|
|
|
def prepare(self, reactor, clock, homeserver):
|
|
|
super().prepare(reactor, clock, homeserver)
|
|
|
+
|
|
|
+ self.store = homeserver.get_datastores().main
|
|
|
+
|
|
|
self.room_creator = homeserver.get_room_creation_handler()
|
|
|
self.persist_event_storage_controller = (
|
|
|
self.hs.get_storage_controllers().persistence
|
|
@@ -87,14 +85,14 @@ class SlavedReceiptTestCase(BaseSlavedStoreTestCase):
|
|
|
|
|
|
def test_return_empty_with_no_data(self):
|
|
|
res = self.get_success(
|
|
|
- self.master_store.get_receipts_for_user(
|
|
|
+ self.store.get_receipts_for_user(
|
|
|
OUR_USER_ID, [ReceiptTypes.READ, ReceiptTypes.READ_PRIVATE]
|
|
|
)
|
|
|
)
|
|
|
self.assertEqual(res, {})
|
|
|
|
|
|
res = self.get_success(
|
|
|
- self.master_store.get_receipts_for_user_with_orderings(
|
|
|
+ self.store.get_receipts_for_user_with_orderings(
|
|
|
OUR_USER_ID,
|
|
|
[ReceiptTypes.READ, ReceiptTypes.READ_PRIVATE],
|
|
|
)
|
|
@@ -102,7 +100,7 @@ class SlavedReceiptTestCase(BaseSlavedStoreTestCase):
|
|
|
self.assertEqual(res, {})
|
|
|
|
|
|
res = self.get_success(
|
|
|
- self.master_store.get_last_receipt_event_id_for_user(
|
|
|
+ self.store.get_last_receipt_event_id_for_user(
|
|
|
OUR_USER_ID,
|
|
|
self.room_id1,
|
|
|
[ReceiptTypes.READ, ReceiptTypes.READ_PRIVATE],
|
|
@@ -121,20 +119,20 @@ class SlavedReceiptTestCase(BaseSlavedStoreTestCase):
|
|
|
|
|
|
# Send public read receipt for the first event
|
|
|
self.get_success(
|
|
|
- self.master_store.insert_receipt(
|
|
|
+ self.store.insert_receipt(
|
|
|
self.room_id1, ReceiptTypes.READ, OUR_USER_ID, [event1_1_id], {}
|
|
|
)
|
|
|
)
|
|
|
# Send private read receipt for the second event
|
|
|
self.get_success(
|
|
|
- self.master_store.insert_receipt(
|
|
|
+ self.store.insert_receipt(
|
|
|
self.room_id1, ReceiptTypes.READ_PRIVATE, OUR_USER_ID, [event1_2_id], {}
|
|
|
)
|
|
|
)
|
|
|
|
|
|
# Test we get the latest event when we want both private and public receipts
|
|
|
res = self.get_success(
|
|
|
- self.master_store.get_receipts_for_user(
|
|
|
+ self.store.get_receipts_for_user(
|
|
|
OUR_USER_ID, [ReceiptTypes.READ, ReceiptTypes.READ_PRIVATE]
|
|
|
)
|
|
|
)
|
|
@@ -142,26 +140,24 @@ class SlavedReceiptTestCase(BaseSlavedStoreTestCase):
|
|
|
|
|
|
# Test we get the older event when we want only public receipt
|
|
|
res = self.get_success(
|
|
|
- self.master_store.get_receipts_for_user(OUR_USER_ID, [ReceiptTypes.READ])
|
|
|
+ self.store.get_receipts_for_user(OUR_USER_ID, [ReceiptTypes.READ])
|
|
|
)
|
|
|
self.assertEqual(res, {self.room_id1: event1_1_id})
|
|
|
|
|
|
# Test we get the latest event when we want only the public receipt
|
|
|
res = self.get_success(
|
|
|
- self.master_store.get_receipts_for_user(
|
|
|
- OUR_USER_ID, [ReceiptTypes.READ_PRIVATE]
|
|
|
- )
|
|
|
+ self.store.get_receipts_for_user(OUR_USER_ID, [ReceiptTypes.READ_PRIVATE])
|
|
|
)
|
|
|
self.assertEqual(res, {self.room_id1: event1_2_id})
|
|
|
|
|
|
# Test receipt updating
|
|
|
self.get_success(
|
|
|
- self.master_store.insert_receipt(
|
|
|
+ self.store.insert_receipt(
|
|
|
self.room_id1, ReceiptTypes.READ, OUR_USER_ID, [event1_2_id], {}
|
|
|
)
|
|
|
)
|
|
|
res = self.get_success(
|
|
|
- self.master_store.get_receipts_for_user(OUR_USER_ID, [ReceiptTypes.READ])
|
|
|
+ self.store.get_receipts_for_user(OUR_USER_ID, [ReceiptTypes.READ])
|
|
|
)
|
|
|
self.assertEqual(res, {self.room_id1: event1_2_id})
|
|
|
|
|
@@ -172,12 +168,12 @@ class SlavedReceiptTestCase(BaseSlavedStoreTestCase):
|
|
|
|
|
|
# Test new room is reflected in what the method returns
|
|
|
self.get_success(
|
|
|
- self.master_store.insert_receipt(
|
|
|
+ self.store.insert_receipt(
|
|
|
self.room_id2, ReceiptTypes.READ_PRIVATE, OUR_USER_ID, [event2_1_id], {}
|
|
|
)
|
|
|
)
|
|
|
res = self.get_success(
|
|
|
- self.master_store.get_receipts_for_user(
|
|
|
+ self.store.get_receipts_for_user(
|
|
|
OUR_USER_ID, [ReceiptTypes.READ, ReceiptTypes.READ_PRIVATE]
|
|
|
)
|
|
|
)
|
|
@@ -194,20 +190,20 @@ class SlavedReceiptTestCase(BaseSlavedStoreTestCase):
|
|
|
|
|
|
# Send public read receipt for the first event
|
|
|
self.get_success(
|
|
|
- self.master_store.insert_receipt(
|
|
|
+ self.store.insert_receipt(
|
|
|
self.room_id1, ReceiptTypes.READ, OUR_USER_ID, [event1_1_id], {}
|
|
|
)
|
|
|
)
|
|
|
# Send private read receipt for the second event
|
|
|
self.get_success(
|
|
|
- self.master_store.insert_receipt(
|
|
|
+ self.store.insert_receipt(
|
|
|
self.room_id1, ReceiptTypes.READ_PRIVATE, OUR_USER_ID, [event1_2_id], {}
|
|
|
)
|
|
|
)
|
|
|
|
|
|
# Test we get the latest event when we want both private and public receipts
|
|
|
res = self.get_success(
|
|
|
- self.master_store.get_last_receipt_event_id_for_user(
|
|
|
+ self.store.get_last_receipt_event_id_for_user(
|
|
|
OUR_USER_ID,
|
|
|
self.room_id1,
|
|
|
[ReceiptTypes.READ, ReceiptTypes.READ_PRIVATE],
|
|
@@ -217,7 +213,7 @@ class SlavedReceiptTestCase(BaseSlavedStoreTestCase):
|
|
|
|
|
|
# Test we get the older event when we want only public receipt
|
|
|
res = self.get_success(
|
|
|
- self.master_store.get_last_receipt_event_id_for_user(
|
|
|
+ self.store.get_last_receipt_event_id_for_user(
|
|
|
OUR_USER_ID, self.room_id1, [ReceiptTypes.READ]
|
|
|
)
|
|
|
)
|
|
@@ -225,7 +221,7 @@ class SlavedReceiptTestCase(BaseSlavedStoreTestCase):
|
|
|
|
|
|
# Test we get the latest event when we want only the private receipt
|
|
|
res = self.get_success(
|
|
|
- self.master_store.get_last_receipt_event_id_for_user(
|
|
|
+ self.store.get_last_receipt_event_id_for_user(
|
|
|
OUR_USER_ID, self.room_id1, [ReceiptTypes.READ_PRIVATE]
|
|
|
)
|
|
|
)
|
|
@@ -233,12 +229,12 @@ class SlavedReceiptTestCase(BaseSlavedStoreTestCase):
|
|
|
|
|
|
# Test receipt updating
|
|
|
self.get_success(
|
|
|
- self.master_store.insert_receipt(
|
|
|
+ self.store.insert_receipt(
|
|
|
self.room_id1, ReceiptTypes.READ, OUR_USER_ID, [event1_2_id], {}
|
|
|
)
|
|
|
)
|
|
|
res = self.get_success(
|
|
|
- self.master_store.get_last_receipt_event_id_for_user(
|
|
|
+ self.store.get_last_receipt_event_id_for_user(
|
|
|
OUR_USER_ID, self.room_id1, [ReceiptTypes.READ]
|
|
|
)
|
|
|
)
|
|
@@ -251,12 +247,12 @@ class SlavedReceiptTestCase(BaseSlavedStoreTestCase):
|
|
|
|
|
|
# Test new room is reflected in what the method returns
|
|
|
self.get_success(
|
|
|
- self.master_store.insert_receipt(
|
|
|
+ self.store.insert_receipt(
|
|
|
self.room_id2, ReceiptTypes.READ_PRIVATE, OUR_USER_ID, [event2_1_id], {}
|
|
|
)
|
|
|
)
|
|
|
res = self.get_success(
|
|
|
- self.master_store.get_last_receipt_event_id_for_user(
|
|
|
+ self.store.get_last_receipt_event_id_for_user(
|
|
|
OUR_USER_ID,
|
|
|
self.room_id2,
|
|
|
[ReceiptTypes.READ, ReceiptTypes.READ_PRIVATE],
|