rename get_devices_by_remote to get_device_updates_by_remote

This commit is contained in:
Hubert Chathi 2019-10-30 14:57:34 -04:00
parent 7d7eac61be
commit bb6cec27a5
4 changed files with 14 additions and 14 deletions

View file

@ -359,7 +359,7 @@ class PerDestinationQueue(object):
last_device_list = self._last_device_list_stream_id last_device_list = self._last_device_list_stream_id
# Retrieve list of new device updates to send to the destination # Retrieve list of new device updates to send to the destination
now_stream_id, results = yield self._store.get_devices_by_remote( now_stream_id, results = yield self._store.get_device_updates_by_remote(
self._destination, last_device_list, limit=limit self._destination, last_device_list, limit=limit
) )
edus = [ edus = [
@ -372,7 +372,7 @@ class PerDestinationQueue(object):
for (edu_type, content) in results for (edu_type, content) in results
] ]
assert len(edus) <= limit, "get_devices_by_remote returned too many EDUs" assert len(edus) <= limit, "get_device_updates_by_remote returned too many EDUs"
return (edus, now_stream_id) return (edus, now_stream_id)

View file

@ -91,7 +91,7 @@ class DeviceWorkerStore(SQLBaseStore):
@trace @trace
@defer.inlineCallbacks @defer.inlineCallbacks
def get_devices_by_remote(self, destination, from_stream_id, limit): def get_device_updates_by_remote(self, destination, from_stream_id, limit):
"""Get a stream of device updates to send to the given remote server. """Get a stream of device updates to send to the given remote server.
Args: Args:
@ -123,8 +123,8 @@ class DeviceWorkerStore(SQLBaseStore):
# stream_id; the rationale being that such a large device list update # stream_id; the rationale being that such a large device list update
# is likely an error. # is likely an error.
updates = yield self.runInteraction( updates = yield self.runInteraction(
"get_devices_by_remote", "get_device_updates_by_remote",
self._get_devices_by_remote_txn, self._get_device_updates_by_remote_txn,
destination, destination,
from_stream_id, from_stream_id,
now_stream_id, now_stream_id,
@ -241,7 +241,7 @@ class DeviceWorkerStore(SQLBaseStore):
return now_stream_id, results return now_stream_id, results
def _get_devices_by_remote_txn( def _get_device_updates_by_remote_txn(
self, txn, destination, from_stream_id, now_stream_id, limit self, txn, destination, from_stream_id, now_stream_id, limit
): ):
"""Return device update information for a given remote destination """Return device update information for a given remote destination

View file

@ -73,7 +73,7 @@ class TypingNotificationsTestCase(unittest.HomeserverTestCase):
"get_received_txn_response", "get_received_txn_response",
"set_received_txn_response", "set_received_txn_response",
"get_destination_retry_timings", "get_destination_retry_timings",
"get_devices_by_remote", "get_device_updates_by_remote",
# Bits that user_directory needs # Bits that user_directory needs
"get_user_directory_stream_pos", "get_user_directory_stream_pos",
"get_current_state_deltas", "get_current_state_deltas",
@ -109,7 +109,7 @@ class TypingNotificationsTestCase(unittest.HomeserverTestCase):
retry_timings_res retry_timings_res
) )
self.datastore.get_devices_by_remote.return_value = (0, []) self.datastore.get_device_updates_by_remote.return_value = (0, [])
def get_received_txn_response(*args): def get_received_txn_response(*args):
return defer.succeed(None) return defer.succeed(None)

View file

@ -72,7 +72,7 @@ class DeviceStoreTestCase(tests.unittest.TestCase):
) )
@defer.inlineCallbacks @defer.inlineCallbacks
def test_get_devices_by_remote(self): def test_get_device_updates_by_remote(self):
device_ids = ["device_id1", "device_id2"] device_ids = ["device_id1", "device_id2"]
# Add two device updates with a single stream_id # Add two device updates with a single stream_id
@ -81,7 +81,7 @@ class DeviceStoreTestCase(tests.unittest.TestCase):
) )
# Get all device updates ever meant for this remote # Get all device updates ever meant for this remote
now_stream_id, device_updates = yield self.store.get_devices_by_remote( now_stream_id, device_updates = yield self.store.get_device_updates_by_remote(
"somehost", -1, limit=100 "somehost", -1, limit=100
) )
@ -89,7 +89,7 @@ class DeviceStoreTestCase(tests.unittest.TestCase):
self._check_devices_in_updates(device_ids, device_updates) self._check_devices_in_updates(device_ids, device_updates)
@defer.inlineCallbacks @defer.inlineCallbacks
def test_get_devices_by_remote_limited(self): def test_get_device_updates_by_remote_limited(self):
# Test breaking the update limit in 1, 101, and 1 device_id segments # Test breaking the update limit in 1, 101, and 1 device_id segments
# first add one device # first add one device
@ -115,20 +115,20 @@ class DeviceStoreTestCase(tests.unittest.TestCase):
# #
# first we should get a single update # first we should get a single update
now_stream_id, device_updates = yield self.store.get_devices_by_remote( now_stream_id, device_updates = yield self.store.get_device_updates_by_remote(
"someotherhost", -1, limit=100 "someotherhost", -1, limit=100
) )
self._check_devices_in_updates(device_ids1, device_updates) self._check_devices_in_updates(device_ids1, device_updates)
# Then we should get an empty list back as the 101 devices broke the limit # Then we should get an empty list back as the 101 devices broke the limit
now_stream_id, device_updates = yield self.store.get_devices_by_remote( now_stream_id, device_updates = yield self.store.get_device_updates_by_remote(
"someotherhost", now_stream_id, limit=100 "someotherhost", now_stream_id, limit=100
) )
self.assertEqual(len(device_updates), 0) self.assertEqual(len(device_updates), 0)
# The 101 devices should've been cleared, so we should now just get one device # The 101 devices should've been cleared, so we should now just get one device
# update # update
now_stream_id, device_updates = yield self.store.get_devices_by_remote( now_stream_id, device_updates = yield self.store.get_device_updates_by_remote(
"someotherhost", now_stream_id, limit=100 "someotherhost", now_stream_id, limit=100
) )
self._check_devices_in_updates(device_ids3, device_updates) self._check_devices_in_updates(device_ids3, device_updates)