Changed to_json to to_dict in Appointment and Job; added to_json to Appointment to actually return a string

This commit is contained in:
Salvatore Ingala
2019-10-11 10:48:35 +07:00
parent e4e83167b7
commit 7c1d8b69c7
6 changed files with 28 additions and 14 deletions

View File

@@ -1,4 +1,5 @@
from os import urandom
import json
from pytest import fixture
from pisa.appointment import Appointment
@@ -35,13 +36,25 @@ def test_init_appointment(appointment_data):
and dispute_delta == appointment.dispute_delta and hash_function == appointment.hash_function)
def test_to_dict(appointment_data):
locator, start_time, end_time, dispute_delta, encrypted_blob_data, cipher, hash_function = appointment_data
appointment = Appointment(locator, start_time, end_time, dispute_delta, encrypted_blob_data, cipher, hash_function)
dict_appointment = appointment.to_dict()
assert (locator == dict_appointment.get("locator") and start_time == dict_appointment.get("start_time")
and end_time == dict_appointment.get("end_time") and dispute_delta == dict_appointment.get("dispute_delta")
and cipher == dict_appointment.get("cipher") and hash_function == dict_appointment.get("hash_function")
and encrypted_blob_data == dict_appointment.get("encrypted_blob"))
def test_to_json(appointment_data):
locator, start_time, end_time, dispute_delta, encrypted_blob_data, cipher, hash_function = appointment_data
appointment = Appointment(locator, start_time, end_time, dispute_delta, encrypted_blob_data, cipher, hash_function)
json_appointment = appointment.to_json()
dict_appointment = json.loads(appointment.to_json())
assert (locator == json_appointment.get("locator") and start_time == json_appointment.get("start_time")
and end_time == json_appointment.get("end_time") and dispute_delta == json_appointment.get("dispute_delta")
and cipher == json_appointment.get("cipher") and hash_function == json_appointment.get("hash_function")
and encrypted_blob_data == json_appointment.get("encrypted_blob"))
assert (locator == dict_appointment.get("locator") and start_time == dict_appointment.get("start_time")
and end_time == dict_appointment.get("end_time") and dispute_delta == dict_appointment.get("dispute_delta")
and cipher == dict_appointment.get("cipher") and hash_function == dict_appointment.get("hash_function")
and encrypted_blob_data == dict_appointment.get("encrypted_blob"))