From 836f5fd8c8e06414c33127d30dbe3788ebc8c33b Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 24 Apr 2018 10:51:17 +0200 Subject: Support arg_to_param_map (dict instead of function) --- bin/test_automata.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'bin/test_automata.py') diff --git a/bin/test_automata.py b/bin/test_automata.py index 5a62931..c21a5a1 100755 --- a/bin/test_automata.py +++ b/bin/test_automata.py @@ -152,7 +152,7 @@ class TestPTA(unittest.TestCase): 'length' : None }) - def test_simulation_param_set(self): + def test_simulation_param_update_function(self): pta = PTA(parameters = ['txpower', 'length']) pta.add_state('IDLE', power = 5) pta.add_state('TX', power = 100) @@ -176,6 +176,30 @@ class TestPTA(unittest.TestCase): 'length' : None }) + def test_simulation_arg_to_param_map(self): + pta = PTA(parameters = ['txpower', 'length']) + pta.add_state('IDLE', power = 5) + pta.add_state('TX', power = 100) + pta.add_transition('UNINITIALIZED', 'IDLE', 'init', energy = 500000, duration = 50000) + pta.add_transition('IDLE', 'IDLE', 'setTxPower', energy = 10000, duration = 120, + arg_to_param_map = {'txpower' : 0}) + pta.add_transition('IDLE', 'TX', 'send', energy = 3, duration = 10) + pta.add_transition('TX', 'IDLE', 'txComplete', timeout = 2000, is_interrupt = True) + trace = [ + ['init'], + ['setTxPower', 10] + ] + expected_energy = 510000 + expected_duration = 50120 + power, duration, state, parameters = pta.simulate(trace) + self.assertEqual(power, expected_energy) + self.assertEqual(duration, expected_duration) + self.assertEqual(state.name, 'IDLE') + self.assertEqual(parameters, { + 'txpower' : 10, + 'length' : None + }) + def test_simulation_arg_function(self): pta = PTA(parameters = ['txpower', 'length']) pta.add_state('IDLE', power = 5) -- cgit v1.2.3