def assert_equal_tds(one, other): """Asserts that both TDs are equal.""" one = ThingDescription(one) if not isinstance(one, ThingDescription) else one other = ThingDescription(other) if not isinstance( other, ThingDescription) else other assert one.to_dict() == other.to_dict()
def test_build_thing(): """Thing objects can be built from ThingDescription objects.""" json_td = ThingDescription(TD_EXAMPLE) thing = json_td.build_thing() td_dict = json_td.to_dict() def assert_same_keys(dict_a, dict_b): assert sorted(list(dict_a.keys())) == sorted(list(dict_b.keys())) assert thing.id == td_dict.get("id") assert thing.title == td_dict.get("title") assert thing.description == td_dict.get("description") assert_same_keys(thing.properties, td_dict.get("properties", {})) assert_same_keys(thing.actions, td_dict.get("actions", {})) assert_same_keys(thing.events, td_dict.get("events", {}))