mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-17 06:04:21 +01:00
extended_appointment - deletes appointment size
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
from teos.responder import TransactionTracker
|
||||
from teos.extended_appointment import ExtendedAppointment
|
||||
|
||||
|
||||
class Builder:
|
||||
"""
|
||||
The :class:`Builder` class is in charge of reconstructing data loaded from the appointments database and build the
|
||||
@@ -26,17 +30,14 @@ class Builder:
|
||||
locator_uuid_map = {}
|
||||
|
||||
for uuid, data in appointments_data.items():
|
||||
appointments[uuid] = {
|
||||
"locator": data.get("locator"),
|
||||
"user_id": data.get("user_id"),
|
||||
"size": len(data.get("encrypted_blob")),
|
||||
}
|
||||
appointment = ExtendedAppointment.from_dict(data)
|
||||
appointments[uuid] = appointment.get_summary()
|
||||
|
||||
if data.get("locator") in locator_uuid_map:
|
||||
locator_uuid_map[data.get("locator")].append(uuid)
|
||||
if appointment.locator in locator_uuid_map:
|
||||
locator_uuid_map[appointment.locator].append(uuid)
|
||||
|
||||
else:
|
||||
locator_uuid_map[data.get("locator")] = [uuid]
|
||||
locator_uuid_map[appointment.locator] = [uuid]
|
||||
|
||||
return appointments, locator_uuid_map
|
||||
|
||||
@@ -64,17 +65,14 @@ class Builder:
|
||||
tx_tracker_map = {}
|
||||
|
||||
for uuid, data in tracker_data.items():
|
||||
trackers[uuid] = {
|
||||
"penalty_txid": data.get("penalty_txid"),
|
||||
"locator": data.get("locator"),
|
||||
"user_id": data.get("user_id"),
|
||||
}
|
||||
tracker = TransactionTracker.from_dict(data)
|
||||
trackers[uuid] = tracker.get_summary()
|
||||
|
||||
if data.get("penalty_txid") in tx_tracker_map:
|
||||
tx_tracker_map[data.get("penalty_txid")].append(uuid)
|
||||
if tracker.penalty_txid in tx_tracker_map:
|
||||
tx_tracker_map[tracker.penalty_txid].append(uuid)
|
||||
|
||||
else:
|
||||
tx_tracker_map[data.get("penalty_txid")] = [uuid]
|
||||
tx_tracker_map[tracker.penalty_txid] = [uuid]
|
||||
|
||||
return trackers, tx_tracker_map
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ class ExtendedAppointment(Appointment):
|
||||
Returns:
|
||||
:obj:`dict`: the appointment summary.
|
||||
"""
|
||||
return {"locator": self.locator, "user_id": self.user_id, "size": len(self.encrypted_blob)}
|
||||
return {"locator": self.locator, "user_id": self.user_id}
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, appointment_data):
|
||||
|
||||
@@ -47,7 +47,6 @@ def test_build_appointments():
|
||||
assert uuid in appointments_data.keys()
|
||||
assert appointments_data[uuid].get("locator") == appointment.get("locator")
|
||||
assert appointments_data[uuid].get("user_id") == appointment.get("user_id")
|
||||
assert len(appointments_data[uuid].get("encrypted_blob")) == appointment.get("size")
|
||||
assert uuid in locator_uuid_map[appointment.get("locator")]
|
||||
|
||||
|
||||
|
||||
@@ -45,7 +45,6 @@ def test_get_summary(appointment_data):
|
||||
assert ExtendedAppointment.from_dict(appointment_data).get_summary() == {
|
||||
"locator": appointment_data["locator"],
|
||||
"user_id": appointment_data["user_id"],
|
||||
"size": len(appointment_data["encrypted_blob"]),
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user