mirror of
https://github.com/pyMC-dev/pyMC_Repeater.git
synced 2026-06-20 18:15:35 +02:00
Refactor contact trimming logic for improved readability by consolidating function calls into single lines. Update related test cases for consistency.
This commit is contained in:
@@ -418,9 +418,7 @@ class CompanionAPIEndpoints:
|
||||
# that every other path honors. Trim favourite-aware (oldest non-favourites
|
||||
# first) so persisted contacts never exceed max_contacts.
|
||||
try:
|
||||
removed = trim_companion_contacts_to_fit(
|
||||
sqlite_handler, companion_hash, max_contacts
|
||||
)
|
||||
removed = trim_companion_contacts_to_fit(sqlite_handler, companion_hash, max_contacts)
|
||||
except ValueError as exc:
|
||||
raise cherrypy.HTTPError(
|
||||
409,
|
||||
|
||||
@@ -341,9 +341,7 @@ class TestImportRepeaterContactsCap:
|
||||
@classmethod
|
||||
def _bridge(cls, max_contacts):
|
||||
contacts = SimpleNamespace(max_contacts=max_contacts, loaded=None)
|
||||
contacts.load_from_dicts = lambda records: setattr(
|
||||
contacts, "loaded", list(records)
|
||||
)
|
||||
contacts.load_from_dicts = lambda records: setattr(contacts, "loaded", list(records))
|
||||
return SimpleNamespace(_companion_hash=cls._HASH, contacts=contacts)
|
||||
|
||||
def test_import_over_cap_trims_to_fit(self, tmp_path):
|
||||
@@ -396,9 +394,7 @@ class TestImportRepeaterContactsCap:
|
||||
import cherrypy
|
||||
|
||||
h = self._handler(tmp_path)
|
||||
self._save_contacts(
|
||||
h, [self._contact(i, flags=1, lastmod=i) for i in range(51)]
|
||||
)
|
||||
self._save_contacts(h, [self._contact(i, flags=1, lastmod=i) for i in range(51)])
|
||||
self._seed_adverts(h, 1)
|
||||
bridge = self._bridge(max_contacts=50)
|
||||
ep = self._endpoint(h, bridge, {"companion_name": "c"})
|
||||
|
||||
Reference in New Issue
Block a user