mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-18 06:34:19 +01:00
Updates Builder unit tests
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
from queue import Queue
|
||||||
|
|
||||||
from pisa.builder import Builder
|
from pisa.builder import Builder
|
||||||
from test.pisa.unit.conftest import get_random_value_hex, generate_dummy_appointment, generate_dummy_tracker
|
from test.pisa.unit.conftest import get_random_value_hex, generate_dummy_appointment, generate_dummy_tracker
|
||||||
@@ -29,8 +30,9 @@ def test_build_appointments():
|
|||||||
# Check that the created appointments match the data
|
# Check that the created appointments match the data
|
||||||
for uuid, appointment in appointments.items():
|
for uuid, appointment in appointments.items():
|
||||||
assert uuid in appointments_data.keys()
|
assert uuid in appointments_data.keys()
|
||||||
assert appointments_data[uuid] == appointment.to_dict()
|
assert appointments_data[uuid].get("locator") == appointment.get("locator")
|
||||||
assert uuid in locator_uuid_map[appointment.locator]
|
assert appointments_data[uuid].get("end_time") == appointment.get("end_time")
|
||||||
|
assert uuid in locator_uuid_map[appointment.get("locator")]
|
||||||
|
|
||||||
|
|
||||||
def test_build_trackers():
|
def test_build_trackers():
|
||||||
@@ -55,17 +57,18 @@ def test_build_trackers():
|
|||||||
# Check that the built trackers match the data
|
# Check that the built trackers match the data
|
||||||
for uuid, tracker in trackers.items():
|
for uuid, tracker in trackers.items():
|
||||||
assert uuid in trackers_data.keys()
|
assert uuid in trackers_data.keys()
|
||||||
tracker_dict = tracker.to_dict()
|
|
||||||
|
|
||||||
# The locator is not part of the tracker_data found in the database (for now)
|
assert tracker.get("penalty_txid") == trackers_data[uuid].get("penalty_txid")
|
||||||
assert trackers_data[uuid] == tracker_dict
|
assert tracker.get("locator") == trackers_data[uuid].get("locator")
|
||||||
assert uuid in tx_tracker_map[tracker.penalty_txid]
|
assert tracker.get("appointment_end") == trackers_data[uuid].get("appointment_end")
|
||||||
|
assert uuid in tx_tracker_map[tracker.get("penalty_txid")]
|
||||||
|
|
||||||
|
|
||||||
def test_build_block_queue():
|
def test_populate_block_queue():
|
||||||
# Create some random block hashes and construct the queue with them
|
# Create some random block hashes and construct the queue with them
|
||||||
blocks = [get_random_value_hex(32) for _ in range(10)]
|
blocks = [get_random_value_hex(32) for _ in range(10)]
|
||||||
queue = Builder.build_block_queue(blocks)
|
queue = Queue()
|
||||||
|
Builder.populate_block_queue(queue, blocks)
|
||||||
|
|
||||||
# Make sure every block is in the queue and that there are not additional ones
|
# Make sure every block is in the queue and that there are not additional ones
|
||||||
while not queue.empty():
|
while not queue.empty():
|
||||||
|
|||||||
Reference in New Issue
Block a user