Coverage for test_object_editing.py: 99%
688 statements
« prev ^ index » next coverage.py v7.2.7, created at 2024-04-10 15:08 +0100
« prev ^ index » next coverage.py v7.2.7, created at 2024-04-10 15:08 +0100
1#-----------------------------------------------------------------------------------
2# System tests for the object configuration editing functions
3#
4# -run_instrument_linking_tests - single and double line instruments
5# - basic linking of instruments (test linking works for block sections)
6# - change of item ID (test change gets reflected in linked instrument)
7# - deletion of instrument (test linking gets removed from linked instrument)
8# - run_point_chaining_tests
9# - basic chaining of points (test auto switching of chained points works)
10# - change of item ID (test change gets reflected in upstream chained point)
11# - deletion of point (test chaining gets removed from upstream point)
12# - run_mirrored_section_tests
13# - basic mirroring of sections (update on change of mirrored sections)
14# - change of item ID (test change gets reflected in upstream section)
15# - deletion of section (test chaining gets removed from upstream section)
16# - run_mode_change_tests (toggling of edit/run mode)
17# - Signals are only overridden on track section ahead in run mode
18# - Signals are not overridden on track section ahead in edit mode
19# - section state is maintained from run mode => edit mode => run mode
20# - run_change_of_item_id_tests
21# - initial configuration of signal interlocking tables
22# - point interlocking tables are correctly populated to match
23# - test the basic interlocking of signals against points and instruments
24# - Signal timed sequence configuration tables
25# - Timed signal IDs are updated to reflect change of signal ID
26# - Timed signal IDs are removed to reflect deletion of signals
27# - Signal interlocking configuration tables
28# - signal ahead IDs are updated to reflect change of signal ID
29# - signal ahead IDs are removed to reflect deletion of signals
30# - opposing signal IDs are updated to reflect change of signal ID
31# - opposing signal IDs are removed to reflect deletion of signals
32# - instrument ahead IDs are updated to reflect change of instrument ID
33# - instrument ahead IDs are removed to reflect deletion of instruments
34# - interlocked point IDs are updated to reflect change of point ID
35# - interlocked point IDs are removed to reflect deletion of points
36# - interlocked section IDs are updated to reflect change of section IDs
37# - interlocked section IDs are removed to reflect deletion of section
38# - Signal Track Occupancy Automation Tables:
39# - Section ahead/behind IDs are updated to reflect change of section ID
40# - Section ahead/behind IDs are removed to reflect deletion of section
41# - Track Sensor Route Tables
42# - Route point IDs are updated to reflect change of point ID
43# - Route point IDs are removed to reflect deletion of point
44# - Route section IDs are updated to reflect change of section ID
45# - Route section IDs are removed to reflect deletion of section
46# - Line Item ID has successfully been changed (to obtain the branch coverage)
47# - run_reset_objects_tests
48# - test points, signals, instruments and sections are returned to their
49# default state following a layout "reset"
50#-----------------------------------------------------------------------------------
52from system_test_harness import *
54#-----------------------------------------------------------------------------------
55# These test the block instrument linking functions, specifically:
56# Linked instruments should be synchronised (block section ahead clear)
57# Change of Item ID in (block instruments remain linked)
58# Deletion of an item (linked instrument updated to remove the deleted instrument)
59#-----------------------------------------------------------------------------------
61def run_instrument_linking_tests(delay:float=0.0):
62 print("Block Instrument linking tests - 4 warnings will be generated")
63 # Add elements to the layout
64 sleep(delay)
65 i1 = create_block_instrument()
66 sleep(delay)
67 select_and_move_objects(i1,100,300,delay=delay)
68 sleep(delay)
69 i2 = create_block_instrument()
70 sleep(delay)
71 select_and_move_objects(i2,300,300,delay=delay)
72 sleep(delay)
73 i3 = create_block_instrument()
74 sleep(delay)
75 select_and_move_objects(i3,100,100,delay=delay)
76 sleep(delay)
77 i4 = create_block_instrument()
78 sleep(delay)
79 select_and_move_objects(i4,300,100,delay=delay)
80 assert_object_configuration(i1,{"itemid":1})
81 assert_object_configuration(i2,{"itemid":2})
82 assert_object_configuration(i3,{"itemid":3})
83 assert_object_configuration(i4,{"itemid":4})
84 # Set up linked instruments (1 <=> 2 and 3 <=> 4)
85 # Instruments 1 and 2 are single line instruments
86 # Note the linked instrument is a string (local or remote)
87 sleep(delay)
88 update_object_configuration(i1,{"linkedto":"2"})
89 update_object_configuration(i2,{"linkedto":"1"})
90 sleep(delay)
91 update_object_configuration(i3,{"itemtype":2,"linkedto":"4"})
92 sleep(delay)
93 update_object_configuration(i4,{"itemtype":2,"linkedto":"3"})
94 # Test the telegraph key / bell of linked instrument - we can't really
95 # make any meaningful assertions other than it doesn't throw an exception
96 sleep(delay)
97 sleep(0.3)
98 click_telegraph_key(1)
99 sleep(0.3)
100 click_telegraph_key(2)
101 sleep(0.3)
102 click_telegraph_key(3)
103 sleep(0.3)
104 click_telegraph_key(4)
105 sleep(0.3)
106 # Test the basic connectivity for single line
107 assert_block_section_ahead_not_clear(1,2,3,4)
108 sleep(delay)
109 set_instrument_clear(1)
110 assert_block_section_ahead_clear(2)
111 assert_block_section_ahead_not_clear(1,3,4)
112 sleep(delay)
113 set_instrument_occupied(1)
114 assert_block_section_ahead_not_clear(1,2,3,4)
115 sleep(delay)
116 set_instrument_blocked(1)
117 assert_block_section_ahead_not_clear(1,2,3,4)
118 sleep(delay)
119 set_instrument_clear(2)
120 assert_block_section_ahead_clear(1)
121 assert_block_section_ahead_not_clear(2,3,4)
122 sleep(delay)
123 set_instrument_occupied(2)
124 assert_block_section_ahead_not_clear(1,2,3,4)
125 sleep(delay)
126 set_instrument_blocked(2)
127 assert_block_section_ahead_not_clear(1,2,3,4)
128 # Test the basic connectivity for double line
129 sleep(delay)
130 set_instrument_clear(3)
131 assert_block_section_ahead_clear(4)
132 assert_block_section_ahead_not_clear(1,2,3)
133 sleep(delay)
134 set_instrument_occupied(3)
135 assert_block_section_ahead_not_clear(1,2,3,4)
136 sleep(delay)
137 set_instrument_blocked(3)
138 assert_block_section_ahead_not_clear(1,2,3,4)
139 sleep(delay)
140 set_instrument_clear(4)
141 assert_block_section_ahead_clear(3)
142 assert_block_section_ahead_not_clear(1,2,4)
143 sleep(delay)
144 set_instrument_occupied(4)
145 assert_block_section_ahead_not_clear(1,2,3,4)
146 sleep(delay)
147 set_instrument_blocked(4)
148 assert_block_section_ahead_not_clear(1,2,3,4)
149 # Change the item IDs - 4 warnings will be generated as we change the IDs
150 update_object_configuration(i1,{"itemid":11})
151 update_object_configuration(i2,{"itemid":12})
152 update_object_configuration(i3,{"itemid":13})
153 update_object_configuration(i4,{"itemid":14})
154 assert_object_configuration(i1,{"itemid":11,"linkedto":"12"})
155 assert_object_configuration(i2,{"itemid":12,"linkedto":"11"})
156 assert_object_configuration(i3,{"itemid":13,"linkedto":"14"})
157 assert_object_configuration(i4,{"itemid":14,"linkedto":"13"})
158 # Test the telegraph key / bell of linked instrument - we can't really
159 # make any meaningful assertions other than it doesn't throw an exception
160 sleep(delay)
161 sleep(0.3)
162 click_telegraph_key(11)
163 sleep(0.3)
164 click_telegraph_key(12)
165 sleep(0.3)
166 click_telegraph_key(13)
167 sleep(0.3)
168 click_telegraph_key(14)
169 sleep(0.3)
170 # Test the basic connectivity for single line
171 assert_block_section_ahead_not_clear(11,12,13,14)
172 sleep(delay)
173 set_instrument_clear(11)
174 assert_block_section_ahead_clear(12)
175 assert_block_section_ahead_not_clear(11,13,14)
176 sleep(delay)
177 set_instrument_occupied(11)
178 assert_block_section_ahead_not_clear(11,12,13,14)
179 sleep(delay)
180 set_instrument_blocked(11)
181 assert_block_section_ahead_not_clear(11,12,13,14)
182 sleep(delay)
183 set_instrument_clear(12)
184 assert_block_section_ahead_clear(11)
185 assert_block_section_ahead_not_clear(12,13,14)
186 sleep(delay)
187 set_instrument_blocked(12)
188 assert_block_section_ahead_not_clear(11,12,13,14)
189 # Test the basic connectivity for double line
190 assert_block_section_ahead_not_clear(11,12,13,14)
191 sleep(delay)
192 set_instrument_clear(13)
193 assert_block_section_ahead_clear(14)
194 assert_block_section_ahead_not_clear(11,12,13)
195 sleep(delay)
196 set_instrument_blocked(13)
197 assert_block_section_ahead_not_clear(11,12,13,14)
198 sleep(delay)
199 set_instrument_clear(14)
200 assert_block_section_ahead_clear(13)
201 assert_block_section_ahead_not_clear(11,12,14)
202 sleep(delay)
203 set_instrument_blocked(14)
204 assert_block_section_ahead_not_clear(11,12,13,14)
205 # Delete the instruments to check linking is removed
206 sleep(delay)
207 select_single_object(i1)
208 assert_objects_selected(i1)
209 delete_selected_objects()
210 sleep(delay)
211 select_single_object(i4)
212 assert_objects_selected(i4)
213 delete_selected_objects()
214 assert_object_configuration(i2,{"linkedto":""})
215 assert_object_configuration(i3,{"linkedto":""})
216 # clean up
217 sleep(delay)
218 select_all_objects()
219 sleep(delay)
220 delete_selected_objects()
221 return()
223#-----------------------------------------------------------------------------------
224# These test the point chaining functions, specifically:
225# Points in a chain should always remain synchronised with the parent
226# Change of Item ID in an auto switched chain (chain remains synchronised)
227# Deletion of an item (chain is updated to remove the deleted point)
228#-----------------------------------------------------------------------------------
230def run_point_chaining_tests(delay:float=0.0):
231 print("Point 'auto-switch' chaining tests")
232 # Add elements to the layout
233 sleep(delay)
234 p1 = create_left_hand_point()
235 sleep(delay)
236 p2 = create_left_hand_point()
237 sleep(delay)
238 p3 = create_left_hand_point()
239 sleep(delay)
240 p4 = create_left_hand_point()
241 assert_object_configuration(p1,{"itemid":1})
242 assert_object_configuration(p2,{"itemid":2})
243 assert_object_configuration(p3,{"itemid":3})
244 assert_object_configuration(p4,{"itemid":4})
245 # Set up a chain of points switching other points (P1 => P2 => P3 => P4)
246 update_object_configuration(p4,{"automatic":True})
247 update_object_configuration(p3,{"alsoswitch":4,"automatic":True})
248 update_object_configuration(p2,{"alsoswitch":3,"automatic":True})
249 update_object_configuration(p1,{"alsoswitch":2})
250 # Test the auto switch is working
251 sleep(delay)
252 assert_points_normal(1,2,3,4)
253 set_points_switched(1)
254 assert_points_switched(1,2,3,4)
255 # Update the ID for P3
256 sleep(delay)
257 assert_object_configuration(p2,{"alsoswitch":3})
258 update_object_configuration(p3,{"itemid":13})
259 assert_object_configuration(p3,{"itemid":13})
260 assert_object_configuration(p2,{"alsoswitch":13})
261 # As P3 is switched by P2 and P2 is switched, P3 should be re-created in
262 # the switched state and therefore all points should remain switched
263 assert_points_switched(1,2,13,4)
264 # Test the switching chain still works with the changed ID
265 sleep(delay)
266 set_points_normal(1)
267 assert_points_normal(1,2,13,4)
268 sleep(delay)
269 set_points_switched(1)
270 assert_points_switched(1,2,13,4)
271 # Update the ID for P1
272 sleep(delay)
273 update_object_configuration(p1,{"itemid":11})
274 assert_object_configuration(p1,{"itemid":11})
275 # As P1 is the start of the chain it should be created in its default
276 # 'normal' state and P2/P3 should be reverted to their normal state
277 assert_points_normal(11,2,13,4)
278 # Test that references are correctly removed on point deletion
279 sleep(delay)
280 assert_object_configuration(p2,{"itemid":2})
281 assert_object_configuration(p1,{"alsoswitch":2})
282 select_single_object(p2)
283 assert_objects_selected(p2)
284 delete_selected_objects()
285 assert_object_configuration(p1,{"alsoswitch":0})
286 # Now the switching chain has been broken
287 sleep(delay)
288 set_points_switched(11)
289 assert_points_switched(11)
290 assert_points_normal(13,4)
291 # Make P3 a manual point and check the P3=>P4 chaining still works
292 sleep(delay)
293 update_object_configuration(p3,{"automatic":False})
294 set_points_switched(13)
295 assert_points_switched(13,4)
296 sleep(delay)
297 set_points_normal(13)
298 assert_points_normal(13,4)
299 # Final test is to delete a point in a chain that is switched
300 # The 'parent' point should remain switched after deletion
301 set_points_switched(13)
302 assert_points_switched(13,4)
303 select_single_object(p4)
304 assert_objects_selected(p4)
305 delete_selected_objects()
306 assert_points_switched(13)
307 # clean up
308 sleep(delay)
309 select_all_objects()
310 sleep(delay)
311 delete_selected_objects()
312 return()
314#-----------------------------------------------------------------------------------
315# These test the mirrored sections functions, specifically:
316# Mirrored sections in a chain should be updated with any changes to the parent
317# Change of Item ID in an mirrored section chain (chain remains synchronised)
318# Deletion of an item (chain is updated to remove the deleted section)
319# Use case of two sections mirroring each other - should remain synchronised
320#-----------------------------------------------------------------------------------
322def run_mirrored_section_tests(delay:float=0.0):
323 print("Mirrored Section tests")
324 t1 = create_track_section()
325 sleep(delay)
326 t2 = create_track_section()
327 sleep(delay)
328 t3 = create_track_section()
329 sleep(delay)
330 t4 = create_track_section()
331 # Check the default item IDs have been assigned correctly
332 assert_object_configuration(t1,{"itemid":1})
333 assert_object_configuration(t2,{"itemid":2})
334 assert_object_configuration(t3,{"itemid":3})
335 assert_object_configuration(t4,{"itemid":4})
336 # Set up a chain of Mirrored sections (P1 => P2 => P3 => P4)
337 # Note that section IDs are strings rather than integers
338 update_object_configuration(t4,{"mirror":'3'})
339 update_object_configuration(t3,{"mirror":'2'})
340 update_object_configuration(t2,{"mirror":'1'})
341 # Test the basic mirroring is working - Note that updating
342 # mirrored is not recursive - When a change is made to one
343 # section then only the 'mirrored' section is updated.
344 # Changes are not propogated further if that section is
345 # also 'mirrored' by another section
346 sleep(delay)
347 set_run_mode()
348 assert_sections_clear(1,2,3,4)
349 sleep(delay)
350 # Section 1 is mirrored by section 2
351 set_sections_occupied(1)
352 assert_sections_occupied(1,2,3,4)
353 sleep(delay)
354 set_sections_clear(1)
355 assert_sections_clear(1,2,3,4)
356 # Section 2 is mirrored by section 3
357 sleep(delay)
358 set_sections_occupied(2)
359 assert_sections_occupied(2,3,4)
360 assert_sections_clear(1)
361 sleep(delay)
362 set_sections_clear(2)
363 assert_sections_clear(1,2,3,4)
364 # Section 3 is mirrored by section 2
365 sleep(delay)
366 set_sections_occupied(3)
367 assert_sections_occupied(3,4)
368 assert_sections_clear(1,2)
369 sleep(delay)
370 set_sections_clear(3)
371 assert_sections_clear(1,2,3,4)
372 # Update the ID for T3
373 sleep(delay)
374 set_edit_mode()
375 update_object_configuration(t3,{"itemid":13})
376 assert_object_configuration(t3,{"itemid":13})
377 assert_object_configuration(t4,{"mirror":'13'})
378 sleep(delay)
379 set_run_mode()
380 # Test the mirroring still works
381 sleep(delay)
382 set_sections_occupied(1)
383 assert_sections_occupied(1,2,13,4)
384 sleep(delay)
385 set_sections_clear(1)
386 assert_sections_clear(1,2,13,4)
387 # Delete T3
388 sleep(delay)
389 set_edit_mode()
390 select_single_object(t3)
391 delete_selected_objects()
392 assert_object_configuration(t4,{"mirror":''})
393 sleep(delay)
394 set_run_mode()
395 # The mirrored chain should be broken
396 sleep(delay)
397 set_sections_occupied(1)
398 assert_sections_occupied(1,2)
399 assert_sections_clear(4)
400 sleep(delay)
401 set_sections_clear(1)
402 assert_sections_clear(1,2,4)
403 # Setup sections 1 and 2 to mirror each other
404 sleep(delay)
405 set_edit_mode()
406 update_object_configuration(t1,{"mirror":'2'})
407 sleep(delay)
408 set_run_mode()
409 # Section 1 is mirrored by section 2
410 sleep(delay)
411 set_sections_occupied(1)
412 assert_sections_occupied(1,2)
413 sleep(delay)
414 set_sections_clear(1)
415 assert_sections_clear(1,2)
416 # Section 2 is mirrored by section 1
417 sleep(delay)
418 set_sections_occupied(2)
419 assert_sections_occupied(1,2)
420 sleep(delay)
421 set_sections_clear(2)
422 assert_sections_clear(1,2)
423 # clean up
424 sleep(delay)
425 set_edit_mode()
426 sleep(delay)
427 select_all_objects()
428 delete_selected_objects()
429 return()
431#-----------------------------------------------------------------------------------
432# These test the changes between Run and edit mode, specifically:
433# Section state from run mode is 'remembered' during edit mode
434#-----------------------------------------------------------------------------------
436def run_mode_change_tests(delay:float=0.0):
437 print("Mode Change tests")
438 # Add elements to the layout
439 sleep(delay)
440 s1 = create_colour_light_signal()
441 sleep(delay)
442 t1 = create_track_section()
443 sleep(delay)
444 assert_object_configuration(s1,{"itemid":1})
445 assert_object_configuration(t1,{"itemid":1})
446 # Configure Signal 1 to be overridden if Section 1 is occupied
447 update_object_configuration(s1,{
448 "tracksections":[0,[[1,0,0],[1,0,0],[1,0,0],[1,0,0],[1,0,0]]],
449 "overridesignal":True})
450 # Test the override works
451 sleep(delay)
452 set_run_mode()
453 set_signals_off(1)
454 assert_signals_override_clear(1)
455 assert_signals_PROCEED(1)
456 sleep(delay)
457 set_sections_occupied(1)
458 assert_signals_override_set(1)
459 assert_signals_DANGER(1)
460 # Set edit mode - Overrides are not maintained in Edit mode
461 sleep(delay)
462 set_edit_mode()
463 assert_signals_override_clear(1)
464 assert_signals_PROCEED(1)
465 # Return to Run mode - Overrides should be re-instated
466 sleep(delay)
467 set_run_mode()
468 assert_signals_override_set(1)
469 assert_signals_DANGER(1)
470 # Clear the section (and the Override)
471 sleep(delay)
472 set_sections_clear(1)
473 assert_signals_override_clear(1)
474 assert_signals_PROCEED(1)
475 # Set edit trhen run mode - section remains clear
476 sleep(delay)
477 set_edit_mode()
478 sleep(delay)
479 set_run_mode()
480 assert_signals_override_clear(1)
481 assert_signals_PROCEED(1)
482 # clean up
483 sleep(delay)
484 set_edit_mode()
485 sleep(delay)
486 select_all_objects()
487 delete_selected_objects()
488 return()
490#-----------------------------------------------------------------------------------
491# This function tests the basic interlocking and override functionality
492# before and after the item IDs are changed
493#-----------------------------------------------------------------------------------
495def test_interlocking_and_overrides(delay,sig1,sig2,sig3,sig4,point1,point2,block1,block2,sec1,sec2,sec3):
496 # Test the basic interlocking for signal 1 (in run mode)
497 sleep(delay)
498 set_run_mode()
499 # Initial (default) configuration
500 assert_points_unlocked(point1,point2)
501 assert_block_section_ahead_not_clear(block1)
502 assert_sections_clear(sec1,sec2,sec3)
503 assert_signals_locked(sig1)
504 # Clear the instrument and switch the points to unlock the signal
505 sleep(delay)
506 set_points_switched(point1,point2)
507 assert_signals_locked(sig1)
508 sleep(delay)
509 set_instrument_clear(block2)
510 assert_signals_unlocked(sig1)
511 # Test interlocking of signal with points
512 sleep(delay)
513 set_points_normal(point1)
514 assert_signals_locked(sig1)
515 sleep(delay)
516 set_points_switched(point1)
517 assert_signals_unlocked(sig1)
518 sleep(delay)
519 set_points_normal(point2)
520 assert_signals_locked(sig1)
521 sleep(delay)
522 set_points_switched(point2)
523 assert_signals_unlocked(sig1)
524 # Test interlocking of signal with track sections
525 sleep(delay)
526 set_sections_occupied(sec1)
527 assert_signals_locked(sig1)
528 sleep(delay)
529 set_sections_clear(sec1)
530 assert_signals_unlocked(sig1)
531 sleep(delay)
532 set_sections_occupied(sec2)
533 assert_signals_locked(sig1)
534 sleep(delay)
535 set_sections_clear(sec2)
536 assert_signals_unlocked(sig1)
537 sleep(delay)
538 set_sections_occupied(sec3)
539 assert_signals_locked(sig1)
540 sleep(delay)
541 set_sections_clear(sec3)
542 assert_signals_unlocked(sig1)
543 # Test interlocking of points with signal
544 sleep(delay)
545 set_signals_off(sig1)
546 assert_points_locked(point1,point2)
547 sleep(delay)
548 set_signals_on(sig1)
549 assert_points_unlocked(point1,point2)
550 # Test interlocking of signal with conflicting signals
551 sleep(delay)
552 set_signals_off(sig2)
553 assert_signals_locked(sig1)
554 sleep(delay)
555 set_signals_on(sig2)
556 assert_signals_unlocked(sig1)
557 sleep(delay)
558 set_signals_off(sig3)
559 assert_signals_locked(sig1)
560 sleep(delay)
561 set_signals_on(sig3)
562 assert_signals_unlocked(sig1)
563 # Test interlocking of signal with block instrument
564 sleep(delay)
565 set_instrument_blocked(block2)
566 assert_signals_locked(sig1)
567 sleep(delay)
568 set_instrument_clear(block2)
569 assert_signals_unlocked(sig1)
570 sleep(delay)
571 set_instrument_occupied(block2)
572 assert_signals_locked(sig1)
573 sleep(delay)
574 set_instrument_clear(block2)
575 assert_signals_unlocked(sig1)
576 # Test the signal overrides (on track section occupied)
577 assert_signals_DANGER(sig1)
578 sleep(delay)
579 set_signals_off(sig1)
580 assert_signals_override_clear(sig1)
581 assert_signals_CAUTION(sig1)
582 sleep(delay)
583 set_sections_occupied(sec1)
584 assert_signals_override_set(sig1)
585 assert_signals_DANGER(sig1)
586 sleep(delay)
587 set_sections_clear(sec1)
588 assert_signals_override_clear(sig1)
589 assert_signals_CAUTION(sig1)
590 sleep(delay)
591 set_sections_occupied(sec2)
592 assert_signals_override_set(sig1)
593 assert_signals_DANGER(sig1)
594 sleep(delay)
595 set_sections_clear(sec2)
596 assert_signals_override_clear(sig1)
597 assert_signals_CAUTION(sig1)
598 sleep(delay)
599 set_sections_occupied(sec3)
600 assert_signals_override_set(sig1)
601 assert_signals_DANGER(sig1)
602 sleep(delay)
603 set_sections_clear(sec3)
604 assert_signals_override_clear(sig1)
605 assert_signals_CAUTION(sig1)
606 sleep(delay)
607 set_signals_on(sig1)
608 assert_signals_DANGER(sig1)
609 # Test the signal interaction with the signal ahead
610 sleep(delay)
611 set_signals_off(sig1)
612 assert_signals_CAUTION(sig1)
613 sleep(delay)
614 set_signals_off(sig4)
615 assert_signals_PROCEED(sig1)
616 sleep(delay)
617 set_signals_on(sig4)
618 assert_signals_CAUTION(sig1)
619 sleep(delay)
620 set_signals_on(sig1)
621 assert_signals_DANGER(sig1)
622 # Return everything to its default state
623 sleep(delay)
624 set_instrument_blocked(block2)
625 sleep(delay)
626 set_points_normal(point1,point2)
627 assert_points_unlocked(point1,point2)
628 assert_block_section_ahead_not_clear(block1)
629 assert_sections_clear(sec1,sec2,sec3)
630 assert_signals_locked(sig1)
631 sleep(delay)
632 set_edit_mode()
633 return()
635#-----------------------------------------------------------------------------------
636# These test the Item ID update functions, specifically:
637# Update of point interlocking when Signal ID is changed or deleted
638# Update of signal ahead value when Signal ID is changed or deleted
639# Update of signal interlocking when Signal ID is changed or deleted
640# Update of signal interlocking when Point ID is changed or deleted
641# Update of signal interlocking when Instrument ID is changed or deleted
642# Update of signal interlocking when Track Section ID is changed or deleted
643# Update of signal automation (override) when Section ID is changed or deleted
644# Update of Track Sensor route tables to reflect change of Point ID
645# Update of Track Sensor route tables to reflect deletion of Point
646# Update of Track Sensor route tables to reflect change of section ID
647# Update of Track Sensor route tables to reflect deletion of section
648#-----------------------------------------------------------------------------------
650def run_change_of_item_id_tests(delay:float=0.0):
651 print("Change of Item Id tests - 2 warnings will be generated for the Block Instruments")
652 # Add elements to the layout
653 sleep(delay)
654 l1 = create_line()
655 sleep(delay)
656 p1 = create_left_hand_point()
657 sleep(delay)
658 p2 = create_left_hand_point()
659 sleep(delay)
660 s1 = create_colour_light_signal()
661 sleep(delay)
662 s2 = create_colour_light_signal()
663 sleep(delay)
664 s3 = create_colour_light_signal()
665 sleep(delay)
666 s4 = create_colour_light_signal()
667 sleep(delay)
668 t1 = create_track_section()
669 sleep(delay)
670 t2 = create_track_section()
671 sleep(delay)
672 t3 = create_track_section()
673 sleep(delay)
674 ts1 = create_track_sensor()
675 sleep(delay)
676 i1 = create_block_instrument()
677 sleep(delay)
678 i2 = create_block_instrument()
679 sleep(delay)
680 # Test the 'one-up' IDs have been correctly generated
681 assert_object_configuration(l1,{"itemid":1})
682 assert_object_configuration(p1,{"itemid":1})
683 assert_object_configuration(p2,{"itemid":2})
684 assert_object_configuration(s1,{"itemid":1})
685 assert_object_configuration(s2,{"itemid":2})
686 assert_object_configuration(s3,{"itemid":3})
687 assert_object_configuration(s4,{"itemid":4})
688 assert_object_configuration(t1,{"itemid":1})
689 assert_object_configuration(t2,{"itemid":2})
690 assert_object_configuration(t3,{"itemid":3})
691 assert_object_configuration(i1,{"itemid":1})
692 assert_object_configuration(i2,{"itemid":2})
693 assert_object_configuration(ts1,{"itemid":1})
694 sleep(delay)
695 select_and_move_objects(i1,500,200,delay=delay)
696 sleep(delay)
697 select_and_move_objects(i2,800,200,delay=delay)
698 # Link the 2 block instruments (so we can test the interlocking)
699 # Note the linked instrument is a string (local or remote)
700 update_object_configuration(i1,{"linkedto":"2"})
701 update_object_configuration(i2,{"linkedto":"1"})
702 # Set up the interlocking tables and the automation tables for Signal 1
703 # This includes point/signal/inst/section interlocking, track sections & timed signals
704 # Signal is interlocked on instrument 1, section 1 and points 1/2 - Sig ahead is 4
705 # Note the Signal ahead is a string as this can be local or remote
706 update_object_configuration(s1,{
707 "sigroutes":[True,True,True,True,True],
708 "overridesignal": True,
709 "pointinterlock":[
710 [[[1,True],[1,True],[1,True],[1,True],[2,True],[2,True]],"4",1],
711 [[[1,True],[1,True],[1,True],[1,True],[2,True],[2,True]],"4",1],
712 [[[1,True],[1,True],[1,True],[1,True],[2,True],[2,True]],"4",1],
713 [[[1,True],[1,True],[1,True],[1,True],[2,True],[2,True]],"4",1],
714 [[[1,True],[1,True],[1,True],[1,True],[2,True],[2,True]],"4",1] ],
715 "siginterlock":[
716 [ [2, [True, True, True, True, True]],
717 [2, [True, True, True, True, True]],
718 [3, [True, True, True, True, True]],
719 [3, [True, True, True, True, True]] ],
720 [ [2, [True, True, True, True, True]],
721 [2, [True, True, True, True, True]],
722 [3, [True, True, True, True, True]],
723 [3, [True, True, True, True, True]] ],
724 [ [2, [True, True, True, True, True]],
725 [2, [True, True, True, True, True]],
726 [3, [True, True, True, True, True]],
727 [3, [True, True, True, True, True]] ],
728 [ [2, [True, True, True, True, True]],
729 [2, [True, True, True, True, True]],
730 [3, [True, True, True, True, True]],
731 [3, [True, True, True, True, True]] ],
732 [ [2, [True, True, True, True, True]],
733 [2, [True, True, True, True, True]],
734 [3, [True, True, True, True, True]],
735 [3, [True, True, True, True, True]] ] ],
736 "trackinterlock":[[1,2,3],[1,2,3],[1,2,3],[1,2,3],[1,2,3]],
737 "tracksections":[1, [[1,2,3],[1,2,3],[1,2,3],[1,2,3],[1,2,3]] ],
738 "timedsequences":[ [True,2,1,1],
739 [True,2,1,1],
740 [True,3,1,1],
741 [True,2,1,1],
742 [True,2,1,1] ]} )
743 # Assert the point interlocking tables have been configured correctly
744 assert_object_configuration(p1,{
745 "siginterlock":[ [1, [True,True,True,True,True] ] ] } )
746 assert_object_configuration(p2,{
747 "siginterlock":[ [1, [True,True,True,True,True] ] ] } )
748 # Configure another signal for point interlocking
749 update_object_configuration(s2,{
750 "sigroutes":[True,True,True,True,True],
751 "pointinterlock":[
752 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],"",0],
753 [[[1,True],[0,False],[0,False],[0,False],[0,False],[0,False]],"",0],
754 [[[1,True],[0,False],[0,False],[0,True],[0,False],[0,False]],"",0],
755 [[[1,True],[0,False],[0,False],[0,False],[0,False],[0,False]],"",0],
756 [[[1,True],[0,False],[0,False],[0,False],[0,False],[0,False]],"",0] ] } )
757 # Assert the point interlocking tables have been configured correctly
758 assert_object_configuration(p1,{
759 "siginterlock":[ [1, [True,True,True,True,True] ],
760 [2, [False,True,True,True,True] ] ] } )
761 assert_object_configuration(p2,{
762 "siginterlock":[ [1, [True,True,True,True,True] ] ] } )
763 # Set up the route tables for Track Sensor 1
764 update_object_configuration(ts1,{
765 "routeahead":[
766 [[[1,True],[1,True],[1,True],[1,True],[2,True],[2,True]],1],
767 [[[1,True],[1,True],[1,True],[1,True],[2,True],[2,True]],1],
768 [[[1,True],[1,True],[1,True],[1,True],[2,True],[2,True]],1],
769 [[[1,True],[1,True],[1,True],[1,True],[2,True],[2,True]],1],
770 [[[1,True],[1,True],[1,True],[1,True],[2,True],[2,True]],1] ],
771 "routebehind":[
772 [[[1,True],[1,True],[1,True],[1,True],[2,True],[2,True]],1],
773 [[[1,True],[1,True],[1,True],[1,True],[2,True],[2,True]],1],
774 [[[1,True],[1,True],[1,True],[1,True],[2,True],[2,True]],1],
775 [[[1,True],[1,True],[1,True],[1,True],[2,True],[2,True]],1],
776 [[[1,True],[1,True],[1,True],[1,True],[2,True],[2,True]],1] ] } )
777 # Test the interlocking and override functionality before changing the item IDs
778 test_interlocking_and_overrides(delay,sig1=1,sig2=2,sig3=3,sig4=4,
779 point1=1,point2=2,block1=1,block2=2,sec1=1,sec2=2,sec3=3)
780 # Change the IDs of Signal 2, Points 1/2, Instrument 1, Track Section 1 and line 1
781 update_object_configuration(l1,{"itemid":51})
782 update_object_configuration(s1,{"itemid":11})
783 update_object_configuration(s2,{"itemid":12})
784 update_object_configuration(s3,{"itemid":13})
785 update_object_configuration(s4,{"itemid":14})
786 update_object_configuration(p1,{"itemid":21})
787 update_object_configuration(p2,{"itemid":22})
788 update_object_configuration(t1,{"itemid":31})
789 update_object_configuration(t2,{"itemid":32})
790 update_object_configuration(t3,{"itemid":33})
791 update_object_configuration(ts1,{"itemid":61})
792 update_object_configuration(i1,{"itemid":41})
793 update_object_configuration(i2,{"itemid":42})
794 # Test the IDs have been changed
795 assert_object_configuration(l1,{"itemid":51})
796 assert_object_configuration(s1,{"itemid":11})
797 assert_object_configuration(s2,{"itemid":12})
798 assert_object_configuration(s3,{"itemid":13})
799 assert_object_configuration(s4,{"itemid":14})
800 assert_object_configuration(p1,{"itemid":21})
801 assert_object_configuration(p2,{"itemid":22})
802 assert_object_configuration(t1,{"itemid":31})
803 assert_object_configuration(t2,{"itemid":32})
804 assert_object_configuration(t3,{"itemid":33})
805 assert_object_configuration(ts1,{"itemid":61})
806 # Note the linked instrument is a string (local or remote)
807 assert_object_configuration(i1,{"itemid":41,"linkedto":"42"})
808 assert_object_configuration(i2,{"itemid":42,"linkedto":"41"})
809 # Test the signal interlocking and automation tables have been updated correctly
810 assert_object_configuration(s1,{
811 "pointinterlock":[
812 [[[21,True],[21,True],[21,True],[21,True],[22,True],[22,True]],"14",41],
813 [[[21,True],[21,True],[21,True],[21,True],[22,True],[22,True]],"14",41],
814 [[[21,True],[21,True],[21,True],[21,True],[22,True],[22,True]],"14",41],
815 [[[21,True],[21,True],[21,True],[21,True],[22,True],[22,True]],"14",41],
816 [[[21,True],[21,True],[21,True],[21,True],[22,True],[22,True]],"14",41] ],
817 "siginterlock":[
818 [ [12, [True, True, True, True, True]],
819 [12, [True, True, True, True, True]],
820 [13, [True, True, True, True, True]],
821 [13, [True, True, True, True, True]] ],
822 [ [12, [True, True, True, True, True]],
823 [12, [True, True, True, True, True]],
824 [13, [True, True, True, True, True]],
825 [13, [True, True, True, True, True]] ],
826 [ [12, [True, True, True, True, True]],
827 [12, [True, True, True, True, True]],
828 [13, [True, True, True, True, True]],
829 [13, [True, True, True, True, True]] ],
830 [ [12, [True, True, True, True, True]],
831 [12, [True, True, True, True, True]],
832 [13, [True, True, True, True, True]],
833 [13, [True, True, True, True, True]] ],
834 [ [12, [True, True, True, True, True]],
835 [12, [True, True, True, True, True]],
836 [13, [True, True, True, True, True]],
837 [13, [True, True, True, True, True]] ] ],
838 "trackinterlock":[[31,32,33],[31,32,33],[31,32,33],[31,32,33],[31,32,33]],
839 "tracksections":[31,[[31,32,33],[31,32,33],[31,32,33],[31,32,33],[31,32,33]] ],
840 "timedsequences":[ [True,12,1,1],
841 [True,12,1,1],
842 [True,13,1,1],
843 [True,12,1,1],
844 [True,12,1,1] ]} )
845 # Assert the point interlocking tables have been updated correctly
846 assert_object_configuration(p1,{
847 "siginterlock":[ [11, [True,True,True,True,True] ],
848 [12, [False,True,True,True,True] ] ] } )
849 assert_object_configuration(p2,{
850 "siginterlock":[ [11, [True,True,True,True,True] ] ] } )
851 # Test the route tables have been updated correctly for Track Sensor 61
852 assert_object_configuration(ts1,{
853 "routeahead":[
854 [[[21,True],[21,True],[21,True],[21,True],[22,True],[22,True]],31],
855 [[[21,True],[21,True],[21,True],[21,True],[22,True],[22,True]],31],
856 [[[21,True],[21,True],[21,True],[21,True],[22,True],[22,True]],31],
857 [[[21,True],[21,True],[21,True],[21,True],[22,True],[22,True]],31],
858 [[[21,True],[21,True],[21,True],[21,True],[22,True],[22,True]],31] ],
859 "routebehind":[
860 [[[21,True],[21,True],[21,True],[21,True],[22,True],[22,True]],31],
861 [[[21,True],[21,True],[21,True],[21,True],[22,True],[22,True]],31],
862 [[[21,True],[21,True],[21,True],[21,True],[22,True],[22,True]],31],
863 [[[21,True],[21,True],[21,True],[21,True],[22,True],[22,True]],31],
864 [[[21,True],[21,True],[21,True],[21,True],[22,True],[22,True]],31] ] } )
865 # Test the interlocking and override functionality after changing the item IDs
866 test_interlocking_and_overrides(delay,sig1=11,sig2=12,sig3=13,sig4=14,
867 point1=21,point2=22,block1=41,block2=42,sec1=31,sec2=32,sec3=33)
868 # Delete Point 21 and test all references have been removed from the Signals and track Sensors
869 # Note that the point 22 entries will have shuffled down in the list
870 sleep(delay)
871 select_single_object(p1)
872 sleep(delay)
873 delete_selected_objects()
874 # Test the route tables have been updated correctly for Signal 11
875 assert_object_configuration(s1,{
876 "pointinterlock":[
877 [[[22,True],[22,True],[0,False],[0,False],[0,False],[0,False]],"14",41],
878 [[[22,True],[22,True],[0,False],[0,False],[0,False],[0,False]],"14",41],
879 [[[22,True],[22,True],[0,False],[0,False],[0,False],[0,False]],"14",41],
880 [[[22,True],[22,True],[0,False],[0,False],[0,False],[0,False]],"14",41],
881 [[[22,True],[22,True],[0,False],[0,False],[0,False],[0,False]],"14",41] ] })
882 # Test the route tables have been updated correctly for Track Sensor 61
883 assert_object_configuration(ts1,{
884 "routeahead":[
885 [[[22,True],[22,True],[0,False],[0,False],[0,False],[0,False]],31],
886 [[[22,True],[22,True],[0,False],[0,False],[0,False],[0,False]],31],
887 [[[22,True],[22,True],[0,False],[0,False],[0,False],[0,False]],31],
888 [[[22,True],[22,True],[0,False],[0,False],[0,False],[0,False]],31],
889 [[[22,True],[22,True],[0,False],[0,False],[0,False],[0,False]],31] ],
890 "routebehind":[
891 [[[22,True],[22,True],[0,False],[0,False],[0,False],[0,False]],31],
892 [[[22,True],[22,True],[0,False],[0,False],[0,False],[0,False]],31],
893 [[[22,True],[22,True],[0,False],[0,False],[0,False],[0,False]],31],
894 [[[22,True],[22,True],[0,False],[0,False],[0,False],[0,False]],31],
895 [[[22,True],[22,True],[0,False],[0,False],[0,False],[0,False]],31] ] } )
896 # Delete Point 22 and test all references have been removed from Signal 11 and Track Sensor 61
897 sleep(delay)
898 select_single_object(p2)
899 sleep(delay)
900 delete_selected_objects()
901 # Test the interlocking tables have been updated correctly for Signal 11
902 assert_object_configuration(s1,{
903 "pointinterlock":[
904 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],"14",41],
905 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],"14",41],
906 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],"14",41],
907 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],"14",41],
908 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],"14",41] ] })
909 # Test the route tables have been updated correctly for Track Sensor 61
910 assert_object_configuration(ts1,{
911 "routeahead":[
912 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],31],
913 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],31],
914 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],31],
915 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],31],
916 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],31] ],
917 "routebehind":[
918 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],31],
919 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],31],
920 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],31],
921 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],31],
922 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],31] ] } )
923 # Delete signal 12 and test all references have been removed from Signal 11
924 sleep(delay)
925 select_single_object(s2)
926 sleep(delay)
927 delete_selected_objects()
928 assert_object_configuration(s1,{
929 "siginterlock":[
930 [ [13, [True, True, True, True, True]],
931 [13, [True, True, True, True, True]],
932 [0, [False, False, False, False, False]],
933 [0, [False, False, False, False, False]] ],
934 [ [13, [True, True, True, True, True]],
935 [13, [True, True, True, True, True]],
936 [0, [False, False, False, False, False]],
937 [0, [False, False, False, False, False]] ],
938 [ [13, [True, True, True, True, True]],
939 [13, [True, True, True, True, True]],
940 [0, [False, False, False, False, False]],
941 [0, [False, False, False, False, False]] ],
942 [ [13, [True, True, True, True, True]],
943 [13, [True, True, True, True, True]],
944 [0, [False, False, False, False, False]],
945 [0, [False, False, False, False, False]] ],
946 [ [13, [True, True, True, True, True]],
947 [13, [True, True, True, True, True]],
948 [0, [False, False, False, False, False]],
949 [0, [False, False, False, False, False]] ] ],
950 "timedsequences":[ [False,0,0,0],
951 [False,0,0,0],
952 [True,13,1,1],
953 [False,0,0,0],
954 [False,0,0,0] ] } )
955 # Delete signal 13 and test all references have been removed from Signal 11
956 sleep(delay)
957 select_single_object(s3)
958 sleep(delay)
959 delete_selected_objects()
960 assert_object_configuration(s1,{
961 "siginterlock":[
962 [ [0, [False, False, False, False, False]],
963 [0, [False, False, False, False, False]],
964 [0, [False, False, False, False, False]],
965 [0, [False, False, False, False, False]] ],
966 [ [0, [False, False, False, False, False]],
967 [0, [False, False, False, False, False]],
968 [0, [False, False, False, False, False]],
969 [0, [False, False, False, False, False]] ],
970 [ [0, [False, False, False, False, False]],
971 [0, [False, False, False, False, False]],
972 [0, [False, False, False, False, False]],
973 [0, [False, False, False, False, False]] ],
974 [ [0, [False, False, False, False, False]],
975 [0, [False, False, False, False, False]],
976 [0, [False, False, False, False, False]],
977 [0, [False, False, False, False, False]] ],
978 [ [0, [False, False, False, False, False]],
979 [0, [False, False, False, False, False]],
980 [0, [False, False, False, False, False]],
981 [0, [False, False, False, False, False]] ] ],
982 "timedsequences":[ [False,0,0,0],
983 [False,0,0,0],
984 [False,0,0,0],
985 [False,0,0,0],
986 [False,0,0,0] ] } )
987 # Delete signal 14 and test all references have been removed from Signal 11
988 sleep(delay)
989 select_single_object(s4)
990 sleep(delay)
991 delete_selected_objects()
992 assert_object_configuration(s1,{
993 "pointinterlock":[
994 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],"",41],
995 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],"",41],
996 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],"",41],
997 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],"",41],
998 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],"",41] ] } )
999 # Delete Instrument 1 and test all references have been removed from Signal 11
1000 sleep(delay)
1001 select_single_object(i1)
1002 sleep(delay)
1003 delete_selected_objects()
1004 assert_object_configuration(s1,{
1005 "pointinterlock":[
1006 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],"",0],
1007 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],"",0],
1008 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],"",0],
1009 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],"",0],
1010 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],"",0] ] })
1011 # Delete Track Section 31 and test all references have been removed from Signal 1 and Track Sensor 61
1012 sleep(delay)
1013 select_single_object(t1)
1014 sleep(delay)
1015 delete_selected_objects()
1016 # Test the route and interlocking tables have been updated correctly for Signal 11
1017 assert_object_configuration(s1,{
1018 "tracksections":[0,[[0,32,33],[0,32,33],[0,32,33],[0,32,33],[0,32,33]] ],
1019 "trackinterlock":[[0,32,33],[0,32,33],[0,32,33],[0,32,33],[0,32,33]] } )
1020 # Test the route tables have been updated correctly for Track Sensor 61
1021 assert_object_configuration(ts1,{
1022 "routeahead":[
1023 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],0],
1024 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],0],
1025 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],0],
1026 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],0],
1027 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],0] ],
1028 "routebehind":[
1029 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],0],
1030 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],0],
1031 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],0],
1032 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],0],
1033 [[[0,False],[0,False],[0,False],[0,False],[0,False],[0,False]],0] ] } )
1034 # Delete Section 32 and test all references have been removed from Signal 11
1035 sleep(delay)
1036 select_single_object(t2)
1037 sleep(delay)
1038 delete_selected_objects()
1039 assert_object_configuration(s1,{
1040 "tracksections":[0,[[0,0,33],[0,0,33],[0,0,33],[0,0,33],[0,0,33]] ],
1041 "trackinterlock":[[0,0,33],[0,0,33],[0,0,33],[0,0,33],[0,0,33]] } )
1042 # Delete Section 33 and test all references have been removed from Signal 11
1043 sleep(delay)
1044 select_single_object(t3)
1045 sleep(delay)
1046 delete_selected_objects()
1047 assert_object_configuration(s1,{
1048 "tracksections":[0,[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]] ],
1049 "trackinterlock":[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]] } )
1050 # clean up
1051 sleep(delay)
1052 select_all_objects()
1053 delete_selected_objects()
1054 return()
1056#-----------------------------------------------------------------------------------
1057# These test the reset objects functions, specifically:
1058# All points, sections, instruments and signals are returned to their default states
1059#-----------------------------------------------------------------------------------
1061def run_reset_objects_tests(delay:float=0.0):
1062 print("Reset objects back to default state tests")
1063 # Add elements to the layout
1064 sleep(delay)
1065 p1 = create_left_hand_point()
1066 sleep(delay)
1067 s1 = create_colour_light_signal()
1068 sleep(delay)
1069 t1 = create_track_section()
1070 sleep(delay)
1071 i1 = create_block_instrument()
1072 sleep(delay)
1073 i2 = create_block_instrument()
1074 sleep(delay)
1075 select_and_move_objects(i1,500,200,delay=delay)
1076 sleep(delay)
1077 select_and_move_objects(i2,800,200,delay=delay)
1078 # Link the 2 block instruments (so we can test the interlocking)
1079 # Note the linked instrument is a string (local or remote)
1080 update_object_configuration(i1,{"linkedto":"2"})
1081 update_object_configuration(i2,{"linkedto":"1"})
1082 # Set up the signal interlocking tables and the automation tables for Signal 1
1083 # set run mode to configure state (for sections)
1084 set_run_mode()
1085 # set them to their non-default states
1086 sleep(delay)
1087 set_signals_off(1)
1088 sleep(delay)
1089 set_points_switched(1)
1090 sleep(delay)
1091 set_sections_occupied(1)
1092 sleep(delay)
1093 set_instrument_clear(2)
1094 # Test reset in Run Mode
1095 assert_signals_PROCEED(1)
1096 assert_points_switched(1)
1097 assert_sections_occupied(1)
1098 assert_block_section_ahead_clear(1)
1099 assert_block_section_ahead_not_clear(2)
1100 sleep(delay)
1101 reset_layout()
1102 assert_signals_DANGER(1)
1103 assert_points_normal(1)
1104 assert_sections_clear(1)
1105 assert_block_section_ahead_not_clear(1,2)
1106 # Now set to non default states again
1107 sleep(delay)
1108 set_signals_off(1)
1109 sleep(delay)
1110 set_points_switched(1)
1111 sleep(delay)
1112 set_sections_occupied(1)
1113 sleep(delay)
1114 set_instrument_occupied(1)
1115 # Test Reset in edit mode
1116 assert_signals_PROCEED(1)
1117 assert_points_switched(1)
1118 assert_sections_occupied(1)
1119 assert_block_section_ahead_not_clear(1,2)
1120 sleep(delay)
1121 set_edit_mode()
1122 sleep(delay)
1123 reset_layout()
1124 set_run_mode()
1125 assert_signals_DANGER(1)
1126 assert_points_normal(1)
1127 assert_sections_clear(1)
1128 assert_block_section_ahead_not_clear(1,2)
1129 # clean up
1130 sleep(delay)
1131 select_all_objects()
1132 delete_selected_objects()
1133 return()
1135######################################################################################################
1137def run_all_object_editing_tests(delay:float=0.0, shutdown:bool=False):
1138 initialise_test_harness()
1139 set_edit_mode()
1140 run_point_chaining_tests(delay)
1141 run_instrument_linking_tests(delay)
1142 run_mirrored_section_tests(delay)
1143 run_mode_change_tests(delay)
1144 run_change_of_item_id_tests(delay)
1145 run_reset_objects_tests(delay)
1146 if shutdown: report_results()
1148if __name__ == "__main__": 1148 ↛ 1149line 1148 didn't jump to line 1149, because the condition on line 1148 was never true
1149 start_application(lambda:run_all_object_editing_tests(delay=0.0, shutdown=True))
1151###############################################################################################################################