def spy_on_instrumented_hsm(request): chart = InstrumentedHsmEventProcessor() spy = [] chart.augment(other=spy, name="spy") yield chart del spy del chart
def test_spy_topology_b1_2(spy_on_instrumented_hsm): chart = InstrumentedHsmEventProcessor() expected_behavior = \ [ 'START', 'SEARCH_FOR_SUPER_SIGNAL:spy_graph_b1_s3', 'SEARCH_FOR_SUPER_SIGNAL:spy_graph_b1_s2', 'SEARCH_FOR_SUPER_SIGNAL:spy_graph_b1_s1', 'ENTRY_SIGNAL:spy_graph_b1_s1', 'ENTRY_SIGNAL:spy_graph_b1_s2', 'ENTRY_SIGNAL:spy_graph_b1_s3', 'INIT_SIGNAL:spy_graph_b1_s3', 'B:spy_graph_b1_s3', 'B:spy_graph_b1_s2', 'EXIT_SIGNAL:spy_graph_b1_s3', 'SEARCH_FOR_SUPER_SIGNAL:spy_graph_b1_s3', 'SEARCH_FOR_SUPER_SIGNAL:spy_graph_b1_s3', 'ENTRY_SIGNAL:spy_graph_b1_s3', 'INIT_SIGNAL:spy_graph_b1_s3'] chart.start_at(spy_graph_b1_s3) event = Event(signal=signals.B) chart.dispatch(e=event) # pp(list(chart.full.spy)) assert(list(chart.full.spy) == expected_behavior) assert(chart.state_name == 'spy_graph_b1_s3')
def spy_on_instrumented_hsm(request): chart = InstrumentedHsmEventProcessor() spy = [] chart.augment(other=spy, name="spy") yield chart del spy del chart
def test_spy_topology_e1_4(spy_on_instrumented_hsm): chart = InstrumentedHsmEventProcessor() expected_behavior = \ ['START', 'SEARCH_FOR_SUPER_SIGNAL:spy_graph_e1_s5', 'SEARCH_FOR_SUPER_SIGNAL:spy_graph_e1_s4', 'SEARCH_FOR_SUPER_SIGNAL:spy_graph_e1_s3', 'SEARCH_FOR_SUPER_SIGNAL:spy_graph_e1_s2', 'SEARCH_FOR_SUPER_SIGNAL:spy_graph_e1_s1', 'ENTRY_SIGNAL:spy_graph_e1_s1', 'ENTRY_SIGNAL:spy_graph_e1_s2', 'ENTRY_SIGNAL:spy_graph_e1_s3', 'ENTRY_SIGNAL:spy_graph_e1_s4', 'ENTRY_SIGNAL:spy_graph_e1_s5', 'INIT_SIGNAL:spy_graph_e1_s5', 'D:spy_graph_e1_s5', 'D:spy_graph_e1_s4', 'D:spy_graph_e1_s3', 'D:spy_graph_e1_s2', 'D:spy_graph_e1_s1', 'EXIT_SIGNAL:spy_graph_e1_s5', 'SEARCH_FOR_SUPER_SIGNAL:spy_graph_e1_s5', 'EXIT_SIGNAL:spy_graph_e1_s4', 'SEARCH_FOR_SUPER_SIGNAL:spy_graph_e1_s4', 'EXIT_SIGNAL:spy_graph_e1_s3', 'SEARCH_FOR_SUPER_SIGNAL:spy_graph_e1_s3', 'EXIT_SIGNAL:spy_graph_e1_s2', 'SEARCH_FOR_SUPER_SIGNAL:spy_graph_e1_s2', 'SEARCH_FOR_SUPER_SIGNAL:spy_graph_e1_s2', 'ENTRY_SIGNAL:spy_graph_e1_s2', 'INIT_SIGNAL:spy_graph_e1_s2'] chart.start_at(spy_graph_e1_s5) event = Event(signal=signals.D) chart.dispatch(e=event) assert(list(chart.full.spy) == expected_behavior)
def test_trace_topology_a_1(): chart = InstrumentedHsmEventProcessor() chart.start_at(trace_graph_a1_s1) chart.dispatch(Event(signal=signals.A)) pp(chart.full.trace) assert(len(chart.full.trace) == 2) start_trace = chart.full.trace[0] assert(start_trace.start_state == 'top') assert(start_trace.signal is None) assert(start_trace.end_state == 'trace_graph_a1_s1') trans_trace = chart.full.trace[1] trans_trace.start_state == 'trace_graph_a1_s1' trans_trace.end_state == 'trace_graph_a1_s1' trans_trace.signal == 'A'
def test_spy_topology_a_2(): chart = InstrumentedHsmEventProcessor() expected_behavior = \ [ 'START', 'SEARCH_FOR_SUPER_SIGNAL:spy_graph_a1_s1', 'ENTRY_SIGNAL:spy_graph_a1_s1', 'INIT_SIGNAL:spy_graph_a1_s1', 'A:spy_graph_a1_s1', 'EXIT_SIGNAL:spy_graph_a1_s1', 'ENTRY_SIGNAL:spy_graph_a1_s1', 'INIT_SIGNAL:spy_graph_a1_s1' ] chart.start_at(spy_graph_a1_s1) event = Event(signal=signals.A) chart.dispatch(e=event) assert(list(chart.full.spy) == expected_behavior) assert(chart.state_name == 'spy_graph_a1_s1')
def test_spy_topology_b1_2(spy_on_instrumented_hsm): chart = InstrumentedHsmEventProcessor() expected_behavior = \ [ 'START', 'SEARCH_FOR_SUPER_SIGNAL:spy_graph_b1_s3', 'SEARCH_FOR_SUPER_SIGNAL:spy_graph_b1_s2', 'SEARCH_FOR_SUPER_SIGNAL:spy_graph_b1_s1', 'ENTRY_SIGNAL:spy_graph_b1_s1', 'ENTRY_SIGNAL:spy_graph_b1_s2', 'ENTRY_SIGNAL:spy_graph_b1_s3', 'INIT_SIGNAL:spy_graph_b1_s3', 'B:spy_graph_b1_s3', 'B:spy_graph_b1_s2', 'EXIT_SIGNAL:spy_graph_b1_s3', 'SEARCH_FOR_SUPER_SIGNAL:spy_graph_b1_s3', 'SEARCH_FOR_SUPER_SIGNAL:spy_graph_b1_s3', 'ENTRY_SIGNAL:spy_graph_b1_s3', 'INIT_SIGNAL:spy_graph_b1_s3'] chart.start_at(spy_graph_b1_s3) event = Event(signal=signals.B) chart.dispatch(e=event) # pp(list(chart.full.spy)) assert (list(chart.full.spy) == expected_behavior) assert (chart.state_name == 'spy_graph_b1_s3')
def test_spy_topology_e1_4(spy_on_instrumented_hsm): chart = InstrumentedHsmEventProcessor() expected_behavior = \ ['START', 'SEARCH_FOR_SUPER_SIGNAL:spy_graph_e1_s5', 'SEARCH_FOR_SUPER_SIGNAL:spy_graph_e1_s4', 'SEARCH_FOR_SUPER_SIGNAL:spy_graph_e1_s3', 'SEARCH_FOR_SUPER_SIGNAL:spy_graph_e1_s2', 'SEARCH_FOR_SUPER_SIGNAL:spy_graph_e1_s1', 'ENTRY_SIGNAL:spy_graph_e1_s1', 'ENTRY_SIGNAL:spy_graph_e1_s2', 'ENTRY_SIGNAL:spy_graph_e1_s3', 'ENTRY_SIGNAL:spy_graph_e1_s4', 'ENTRY_SIGNAL:spy_graph_e1_s5', 'INIT_SIGNAL:spy_graph_e1_s5', 'D:spy_graph_e1_s5', 'D:spy_graph_e1_s4', 'D:spy_graph_e1_s3', 'D:spy_graph_e1_s2', 'D:spy_graph_e1_s1', 'EXIT_SIGNAL:spy_graph_e1_s5', 'SEARCH_FOR_SUPER_SIGNAL:spy_graph_e1_s5', 'EXIT_SIGNAL:spy_graph_e1_s4', 'SEARCH_FOR_SUPER_SIGNAL:spy_graph_e1_s4', 'EXIT_SIGNAL:spy_graph_e1_s3', 'SEARCH_FOR_SUPER_SIGNAL:spy_graph_e1_s3', 'EXIT_SIGNAL:spy_graph_e1_s2', 'SEARCH_FOR_SUPER_SIGNAL:spy_graph_e1_s2', 'SEARCH_FOR_SUPER_SIGNAL:spy_graph_e1_s2', 'ENTRY_SIGNAL:spy_graph_e1_s2', 'INIT_SIGNAL:spy_graph_e1_s2'] chart.start_at(spy_graph_e1_s5) event = Event(signal=signals.D) chart.dispatch(e=event) assert (list(chart.full.spy) == expected_behavior)
def test_trace_topology_a_1(): chart = InstrumentedHsmEventProcessor() chart.start_at(trace_graph_a1_s1) chart.dispatch(Event(signal=signals.A)) pp(chart.full.trace) assert (len(chart.full.trace) == 2) start_trace = chart.full.trace[0] assert (start_trace.start_state == 'top') assert (start_trace.signal is None) assert (start_trace.end_state == 'trace_graph_a1_s1') trans_trace = chart.full.trace[1] trans_trace.start_state == 'trace_graph_a1_s1' trans_trace.end_state == 'trace_graph_a1_s1' trans_trace.signal == 'A'
def test_spy_topology_a_2(): chart = InstrumentedHsmEventProcessor() expected_behavior = \ [ 'START', 'SEARCH_FOR_SUPER_SIGNAL:spy_graph_a1_s1', 'ENTRY_SIGNAL:spy_graph_a1_s1', 'INIT_SIGNAL:spy_graph_a1_s1', 'A:spy_graph_a1_s1', 'EXIT_SIGNAL:spy_graph_a1_s1', 'ENTRY_SIGNAL:spy_graph_a1_s1', 'INIT_SIGNAL:spy_graph_a1_s1' ] chart.start_at(spy_graph_a1_s1) event = Event(signal=signals.A) chart.dispatch(e=event) assert (list(chart.full.spy) == expected_behavior) assert (chart.state_name == 'spy_graph_a1_s1')
def test_trace_topology_g1_2(): chart = InstrumentedHsmEventProcessor() chart.start_at(trace_graph_g1_s2111) chart.dispatch(Event(signal=signals.E))
def test_trace_topology_g1_2(): chart = InstrumentedHsmEventProcessor() chart.start_at(trace_graph_g1_s2111) chart.dispatch(Event(signal=signals.E))