CoolFace
Apppublic

linpershey/process_mining

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
imp_exp_from_string.py93 linesDownload Raw Back to tests
1import os2import unittest3 4import pm4py5from pm4py.objects.log.importer.xes import importer as xes_importer6from pm4py.objects.petri_net.importer import importer as petri_importer7from pm4py.objects.process_tree.importer import importer as tree_importer8from pm4py.objects.bpmn.importer import importer as bpmn_importer9from pm4py.objects.log.exporter.xes import exporter as xes_exporter10from pm4py.objects.petri_net.exporter import exporter as petri_exporter11from pm4py.objects.process_tree.exporter import exporter as tree_exporter12from pm4py.objects.bpmn.exporter import exporter as bpmn_exporter13 14 15class ImpExpFromString(unittest.TestCase):16    def test_imp_xes_from_str(self):17        F = open(os.path.join("input_data", "running-example.xes"), "rb")18        content = F.read()19        F.close()20        log = xes_importer.deserialize(content)21        self.assertIsNotNone(log)22 23    def test_imp_petri_from_str(self):24        F = open(os.path.join("input_data", "running-example.pnml"), "rb")25        content = F.read()26        F.close()27        net, im, fm = petri_importer.deserialize(content)28        self.assertIsNotNone(net)29        self.assertIsNotNone(im)30 31    def test_imp_tree_from_str(self):32        F = open(os.path.join("input_data", "running-example.ptml"), "rb")33        content = F.read()34        F.close()35        tree = tree_importer.deserialize(content)36        self.assertIsNotNone(tree)37 38    def test_imp_bpmn_from_str(self):39        F = open(os.path.join("input_data", "running-example.bpmn"), "rb")40        content = F.read()41        F.close()42        bpmn_graph = bpmn_importer.deserialize(content)43        self.assertIsNotNone(bpmn_graph)44 45    def test_imp_xes_from_str2(self):46        F = open(os.path.join("input_data", "running-example.xes"), "r")47        content = F.read()48        F.close()49        log = xes_importer.deserialize(content)50        self.assertIsNotNone(log)51 52    def test_imp_petri_from_str2(self):53        F = open(os.path.join("input_data", "running-example.pnml"), "r")54        content = F.read()55        F.close()56        net, im, fm = petri_importer.deserialize(content)57        self.assertIsNotNone(net)58        self.assertIsNotNone(im)59 60    def test_imp_tree_from_str2(self):61        F = open(os.path.join("input_data", "running-example.ptml"), "r")62        content = F.read()63        F.close()64        tree = tree_importer.deserialize(content)65        self.assertIsNotNone(tree)66 67    def test_imp_bpmn_from_str2(self):68        F = open(os.path.join("input_data", "running-example.bpmn"), "r")69        content = F.read()70        F.close()71        bpmn_graph = bpmn_importer.deserialize(content)72        self.assertIsNotNone(bpmn_graph)73 74    def test_exp_xes_to_str(self):75        log = pm4py.read_xes(os.path.join("input_data", "running-example.xes"))76        xes_exporter.serialize(log)77 78    def test_exp_pnml_to_str(self):79        net, im, fm = pm4py.read_pnml(os.path.join("input_data", "running-example.pnml"))80        petri_exporter.serialize(net, im, fm)81 82    def test_exp_ptml_to_str(self):83        tree = pm4py.read_ptml(os.path.join("input_data", "running-example.ptml"))84        tree_exporter.serialize(tree)85 86    def test_exp_bpmn_to_str(self):87        bpmn_graph = pm4py.read_bpmn(os.path.join("input_data", "running-example.bpmn"))88        bpmn_exporter.serialize(bpmn_graph)89 90 91if __name__ == "__main__":92    unittest.main()93