|
|
|
@ -410,6 +410,62 @@ class ApplicationServiceTransactionStoreTestCase(unittest.TestCase): |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ApplicationServiceStoreTypeStreamIds(unittest.HomeserverTestCase): |
|
|
|
|
def make_homeserver(self, reactor, clock): |
|
|
|
|
hs = self.setup_test_homeserver() |
|
|
|
|
return hs |
|
|
|
|
|
|
|
|
|
def prepare(self, hs, reactor, clock): |
|
|
|
|
self.service = Mock(id="foo") |
|
|
|
|
self.store = self.hs.get_datastore() |
|
|
|
|
self.get_success(self.store.set_appservice_state(self.service, "up")) |
|
|
|
|
|
|
|
|
|
def test_get_type_stream_id_for_appservice_no_value(self): |
|
|
|
|
value = self.get_success( |
|
|
|
|
self.store.get_type_stream_id_for_appservice(self.service, "read_receipt") |
|
|
|
|
) |
|
|
|
|
self.assertEquals(value, 0) |
|
|
|
|
|
|
|
|
|
value = self.get_success( |
|
|
|
|
self.store.get_type_stream_id_for_appservice(self.service, "presence") |
|
|
|
|
) |
|
|
|
|
self.assertEquals(value, 0) |
|
|
|
|
|
|
|
|
|
def test_get_type_stream_id_for_appservice_invalid_type(self): |
|
|
|
|
self.get_failure( |
|
|
|
|
self.store.get_type_stream_id_for_appservice(self.service, "foobar"), |
|
|
|
|
ValueError, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
def test_set_type_stream_id_for_appservice(self): |
|
|
|
|
read_receipt_value = 1024 |
|
|
|
|
self.get_success( |
|
|
|
|
self.store.set_type_stream_id_for_appservice( |
|
|
|
|
self.service, "read_receipt", read_receipt_value |
|
|
|
|
) |
|
|
|
|
) |
|
|
|
|
result = self.get_success( |
|
|
|
|
self.store.get_type_stream_id_for_appservice(self.service, "read_receipt") |
|
|
|
|
) |
|
|
|
|
self.assertEqual(result, read_receipt_value) |
|
|
|
|
|
|
|
|
|
self.get_success( |
|
|
|
|
self.store.set_type_stream_id_for_appservice( |
|
|
|
|
self.service, "presence", read_receipt_value |
|
|
|
|
) |
|
|
|
|
) |
|
|
|
|
result = self.get_success( |
|
|
|
|
self.store.get_type_stream_id_for_appservice(self.service, "presence") |
|
|
|
|
) |
|
|
|
|
self.assertEqual(result, read_receipt_value) |
|
|
|
|
|
|
|
|
|
def test_set_type_stream_id_for_appservice_invalid_type(self): |
|
|
|
|
self.get_failure( |
|
|
|
|
self.store.set_type_stream_id_for_appservice(self.service, "foobar", 1024), |
|
|
|
|
ValueError, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# required for ApplicationServiceTransactionStoreTestCase tests |
|
|
|
|
class TestTransactionStore(ApplicationServiceTransactionStore, ApplicationServiceStore): |
|
|
|
|
def __init__(self, database: DatabasePool, db_conn, hs): |
|
|
|
|