예제 #1
0
 def test_update_markings(self):
     test_net = cfc.parse_pnml('test/fixtures/test_net1.pnml')
     checker = cfc.LogChecker(test_net, [])
     checker.update_markings('go right')
     self.assertIn('p2', checker.path_buffer[0].tokens)
     self.assertIn('p4', checker.path_buffer[0].tokens)
     self.assertNotIn('p1', checker.path_buffer[0].tokens)
예제 #2
0
 def test_check_log_multiple_paths_some_valid(self):
     test_net = cfc.parse_pnml('test/fixtures/test_net3.pnml')
     events = ['wake up', 'have coffee', 'go to work', 'start working']
     output = cfc.check_log(test_net,
                            events,
                            expected_final_marking=['p11'])
     self.assertEquals(len(output['missing_tokens']), 0)
     self.assertEquals(len(output['unconsumed_tokens']), 0)
예제 #3
0
 def test_check_events_invalid(self):
     events = ['go left', 'stop']
     test_net = cfc.parse_pnml('test/fixtures/test_net1.pnml')
     checker = cfc.LogChecker(test_net, events)
     checker.check_events()
     self.assertIn('p5', checker.path_buffer[0].tokens)
     self.assertIn('p4', checker.path_buffer[0].missing_tokens)
     self.assertIn('p3', checker.path_buffer[0].tokens)
예제 #4
0
 def test_check_log_multiple_paths_none_valid(self):
     test_net = cfc.parse_pnml('test/fixtures/test_net3.pnml')
     events = [
         'wake up', 'go for a run', 'change', 'go to work', 'start working'
     ]
     output = cfc.check_log(test_net,
                            events,
                            expected_final_marking=['p11'])
     self.assertEquals(output['missing_tokens'], ['p8'])
     self.assertEquals(output['unconsumed_tokens'], ['p7'])
예제 #5
0
 def test_parse_pnml(self):
     parsed_net = cfc.parse_pnml('test/fixtures/test_net1.pnml')
     self.assertEquals(['t1'], parsed_net.transition_lookup['go left'])
     self.assertEquals(['t2'], parsed_net.transition_lookup['go right'])
     self.assertEquals(['t3'], parsed_net.transition_lookup['turn back'])
     self.assertEquals(['t4'], parsed_net.transition_lookup['stop'])
     self.assertEquals(['p1'], parsed_net.transitions['t1'].input_places)
     self.assertIn('p2', parsed_net.transitions['t1'].output_places)
     self.assertIn('p3', parsed_net.transitions['t1'].output_places)
     self.assertEquals(['p1'], parsed_net.transitions['t2'].input_places)
     self.assertIn('p2', parsed_net.transitions['t2'].output_places)
     self.assertIn('p4', parsed_net.transitions['t2'].output_places)
     self.assertEquals(['p3'], parsed_net.transitions['t3'].input_places)
     self.assertEquals(['p4'], parsed_net.transitions['t3'].output_places)
     self.assertIn('p2', parsed_net.transitions['t4'].input_places)
     self.assertIn('p4', parsed_net.transitions['t4'].input_places)
     self.assertEquals(['p5'], parsed_net.transitions['t4'].output_places)
     self.assertIn('p1', parsed_net.initial_marking.tokens)
예제 #6
0
 def test_check_log_single_bad_path(self):
     test_net = cfc.parse_pnml('test/fixtures/test_net1.pnml')
     events = ['go left', 'stop']
     output = cfc.check_log(test_net, events, expected_final_marking=['p5'])
     self.assertEquals(output['missing_tokens'], ['p4'])
     self.assertEquals(output['unconsumed_tokens'], ['p3'])
예제 #7
0
 def test_check_events(self):
     events = ['go right', 'stop']
     test_net = cfc.parse_pnml('test/fixtures/test_net1.pnml')
     checker = cfc.LogChecker(test_net, events)
     checker.check_events()
     self.assertIn('p5', checker.path_buffer[0].tokens)
예제 #8
0
 def _init_shared_data(self, spark_context):
     """Retrieves the ruid mapping and broadcast it to the worker nodes."""
     model = cfc.parse_pnml('models/model1')
     self.initialize_broadcast_variable(spark_context,
                                        name='model1',
                                        value=model)