Exemple #1
0
 def test_002_serialization_deserialization(self):
     prd = prepare_partial_key_dictionary()
     prd2 = prd.to_pickable()
     s = serialize_from_object(prd2)
     prd2 = deserialize_to_object(s)
     prd = PartialRetrievalDictionary().from_pickable(prd2)
     # Tests
     res = prd.get({"_type": "PartOf"})
     self.assertEqual(len(res), 3)
     res = prd.get({"_type": "PartOf", "_child": "B"})
     self.assertEqual(len(res), 2)
     res = prd.get({"_type": "PartOf", "_parent": "A1"})
     self.assertEqual(len(res), 1)
     res = prd.get({"_type": "PartOf", "_parent": "C"})
     self.assertEqual(len(res), 0)
     res = prd.get({"_typer": "PartOf", "_parent": "C"})
     self.assertEqual(len(res), 0)
Exemple #2
0
def get_processor_names_to_processors_dictionary(
        state: PartialRetrievalDictionary):
    """
    Obtain a dictionary with all processor names (a processor may have multiple names) and
    the corresponding Processor object

    :param state:
    :return:
    """
    ps = state.get(Processor.partial_key())
    ps = set(ps)  # Avoid repeating Processor objects
    d = create_dictionary()
    for p in ps:
        for n in p.full_hierarchy_names(state):
            d[n] = p
    return d