From eb6d292d3c5c32edd2ecbc7282309701c0068d0f Mon Sep 17 00:00:00 2001 From: Sergi Delgado Segura Date: Wed, 22 Apr 2020 14:48:00 +0200 Subject: [PATCH] extended_appointment - deletes appointment size --- teos/builder.py | 30 ++++++++++----------- teos/extended_appointment.py | 2 +- test/teos/unit/test_builder.py | 1 - test/teos/unit/test_extended_appointment.py | 1 - 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/teos/builder.py b/teos/builder.py index 0a00a3a..56f489d 100644 --- a/teos/builder.py +++ b/teos/builder.py @@ -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 diff --git a/teos/extended_appointment.py b/teos/extended_appointment.py index 7aa4482..ca6a88b 100644 --- a/teos/extended_appointment.py +++ b/teos/extended_appointment.py @@ -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): diff --git a/test/teos/unit/test_builder.py b/test/teos/unit/test_builder.py index 5b3ec58..f804e54 100644 --- a/test/teos/unit/test_builder.py +++ b/test/teos/unit/test_builder.py @@ -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")] diff --git a/test/teos/unit/test_extended_appointment.py b/test/teos/unit/test_extended_appointment.py index 46f6b1f..bc883fe 100644 --- a/test/teos/unit/test_extended_appointment.py +++ b/test/teos/unit/test_extended_appointment.py @@ -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"]), }