Пример #1
0
 def test_fire_transition_by_name_multiple_illegal_options(self):
     test_net = cfc.Net()
     test_net.add_transition('t2',
                             'sample transition',
                             input_places=['p1', 'p2'],
                             output_places=['p6'])
     test_net.add_transition('t1',
                             'sample transition',
                             input_places=['p1', 'p2', 'p3'],
                             output_places=['p5'])
     test_net.add_transition('t3',
                             'sample transition',
                             input_places=['p4'],
                             output_places=['p7'])
     test_net.add_transition('t4',
                             'different transition',
                             input_places=['p1', 'p3'],
                             output_places=['p8'])
     test_marking = cfc.Marking()
     test_marking.produce_token('p1')
     test_marking.produce_token('p3')
     test_net.fire_transition_by_name('sample transition', test_marking)
     self.assertIn('p5', test_marking.tokens)
     self.assertNotIn('p6', test_marking.tokens)
     self.assertNotIn('p7', test_marking.tokens)
     self.assertNotIn('p8', test_marking.tokens)
Пример #2
0
 def test_resolve_expected_final_marking(self):
     checker = cfc.LogChecker(cfc.Net(), [])
     marking = cfc.Marking()
     marking.tokens = ['p1']
     checker.path_buffer = [marking, marking]
     output = checker.resolve_expected_final_marking(['p1'])
     self.assertEquals(len(output.tokens), 0)
Пример #3
0
 def test_delete_dupllicate_markings(self):
     checker = cfc.LogChecker(cfc.Net(), [])
     marking = cfc.Marking()
     marking.tokens = ['p1']
     checker.path_buffer = [marking, marking, marking]
     checker.delete_duplicate_markings()
     self.assertEquals(len(checker.path_buffer), 1)
Пример #4
0
 def test_test_transition(self):
     test_net = cfc.Net()
     test_net.add_transition('t1',
                             'sample transition',
                             input_places=['p1'],
                             output_places=['p2'])
     test_marking = cfc.Marking()
     result = test_net.test_transition('t1', test_marking)
     self.assertEquals(1, result)
Пример #5
0
 def test_fire_transition_by_name_single_option(self):
     test_net = cfc.Net()
     test_net.add_transition('t1',
                             'sample transition',
                             input_places=['p1'],
                             output_places=['p2'])
     test_marking = cfc.Marking()
     test_marking.produce_token('p1')
     test_net.fire_transition_by_name('sample transition', test_marking)
     self.assertIn('p2', test_marking.tokens)
Пример #6
0
 def test_fire_with_missing(self):
     test_net = cfc.Net()
     test_net.add_transition('t1',
                             'sample transition',
                             input_places=['p1'],
                             output_places=['p2'])
     test_marking = cfc.Marking()
     test_net.fire_transition('t1', test_marking)
     self.assertIn('p2', test_marking.tokens)
     self.assertIn('p1', test_marking.missing_tokens)
Пример #7
0
 def test_add_transition(self):
     test_net = cfc.Net()
     test_net.add_transition('t1',
                             'sample transition',
                             input_places=['p1'],
                             output_places=['p2', 'p3'])
     self.assertEquals(test_net.transition_lookup['sample transition'],
                       ['t1'])
     self.assertEquals(test_net.transitions['t1'].input_places, ['p1'])
     self.assertEquals(test_net.transitions['t1'].output_places,
                       ['p2', 'p3'])
Пример #8
0
 def test_trim_path_buffer(self):
     checker = cfc.LogChecker(cfc.Net(), [])
     good_marking = cfc.Marking()
     bad_marking = cfc.Marking()
     duplicate_marking = cfc.Marking()
     good_marking.tokens = ['p1', 'p2']
     duplicate_marking.tokens = ['p1', 'p2']
     bad_marking.tokens = ['p3']
     bad_marking.missing_tokens = ['p4']
     checker.path_buffer = [good_marking, bad_marking, duplicate_marking]
     checker.trim_path_buffer()
     self.assertEquals(len(checker.path_buffer), 1)
     self.assertEquals(['p1', 'p2'], checker.path_buffer[0].tokens)
Пример #9
0
 def test_keep_least_divergent_markings(self):
     checker = cfc.LogChecker(cfc.Net(), [])
     best_marking = cfc.Marking()
     bad_marking1 = cfc.Marking()
     bad_marking2 = cfc.Marking()
     best_marking.tokens = ['p1']
     bad_marking1.tokens = ['p2']
     bad_marking2.tokens = ['p2']
     best_marking.missing_tokens = ['p4']
     bad_marking1.missing_tokens = ['p4', 'p5']
     bad_marking2.missing_tokens = ['p4', 'p5', 'p6']
     checker.path_buffer = [best_marking, bad_marking1, bad_marking2]
     checker.keep_least_divergent_markings()
     self.assertEquals(len(checker.path_buffer), 1)
     self.assertEquals(['p1'], checker.path_buffer[0].tokens)
Пример #10
0
 def test_fire_transition_by_name_multiple_legal_options(self):
     test_net = cfc.Net()
     test_net.add_transition('t1', 'sample transition', input_places=['p1'])
     test_net.add_transition('t2',
                             'sample transition',
                             input_places=['p1', 'p2'])
     test_net.add_transition('t3', 'sample transition', input_places=['p3'])
     test_net.add_transition('t4',
                             'different transition',
                             input_places=['p1', 'p2'],
                             output_places=['p8'])
     test_marking = cfc.Marking()
     test_marking.produce_token('p1')
     test_marking.produce_token('p2')
     with self.assertRaises(cfc.MultiPathError) as context:
         test_net.fire_transition_by_name('sample transition', test_marking)
         self.assertTrue(
             context.possible_paths == ['t1', 't2'],
             msg="found multiple fireable transitions: ['t1', 't2']")
Пример #11
0
 def test_add_place(self):
     test_net = cfc.Net()
     test_net.add_place('p1', 'Start')
     self.assertEquals(test_net.places['p1'], {'name': 'Start'})
Пример #12
0
 def test_add_arc_out_of_transition(self):
     test_net = cfc.Net()
     test_net.add_transition('t1', 'sample transition')
     test_net.add_arc('t1', 'p2')
     self.assertIn('p2', test_net.transitions['t1'].output_places)
Пример #13
0
 def test_add_arc_into_transition(self):
     test_net = cfc.Net()
     test_net.add_transition('t1', 'sample transition')
     test_net.add_arc('p1', 't1')
     self.assertIn('p1', test_net.transitions['t1'].input_places)