|
| 1 | +"""Config.""" |
| 2 | +from dataclasses import dataclass |
| 3 | +import enum |
| 4 | +from typing import Dict, Callable |
| 5 | + |
| 6 | +from hardware_testing.data.csv_report import CSVReport, CSVSection |
| 7 | + |
| 8 | +from . import ( |
| 9 | + test_connectivity, |
| 10 | + test_z_axis_basic, |
| 11 | + test_x_axis_basic, |
| 12 | + test_l_axis_basic, |
| 13 | + test_z_axis_current_speed, |
| 14 | + test_x_axis_current_speed, |
| 15 | + test_stallguard, |
| 16 | + test_door_switch, |
| 17 | + test_estop, |
| 18 | + test_ui_leds, |
| 19 | + test_uv_lockout_switch, |
| 20 | + test_install_detection, |
| 21 | + test_tof_basic, |
| 22 | + test_tof_functional, |
| 23 | +) |
| 24 | + |
| 25 | + |
| 26 | +class TestSection(enum.Enum): |
| 27 | + """Test Section.""" |
| 28 | + |
| 29 | + CONNECTIVITY = "CONNECTIVITY" |
| 30 | + DOOR_SWITCH = "DOOR_SWITCH" |
| 31 | + ESTOP = "ESTOP" |
| 32 | + Z_AXIS_BASIC = "Z_AXIS_BASIC" |
| 33 | + L_AXIS_BASIC = "L_AXIS_BASIC" |
| 34 | + X_AXIS_BASIC = "X_AXIS_BASIC" |
| 35 | + STALLGUARD = "STALLGUARD" |
| 36 | + UI_LEDS = "UI_LEDS" |
| 37 | + UV_LOCKOUT_SWITCH = "UV_LOCKOUT_SWITCH" |
| 38 | + INSTALL_DETECTION = "INSTALL_DETECTION" |
| 39 | + TOF_BASIC = "TOF_BASIC" |
| 40 | + TOF_FUNCTIONAL = "TOF_FUNCTIONAL" |
| 41 | + Z_AXIS_CURRENT_SPEED = "Z_AXIS_CURRENT_SPEED" |
| 42 | + X_AXIS_CURRENT_SPEED = "X_AXIS_CURRENT_SPEED" |
| 43 | + |
| 44 | + |
| 45 | +@dataclass |
| 46 | +class TestConfig: |
| 47 | + """Test Config.""" |
| 48 | + |
| 49 | + simulate: bool |
| 50 | + tests: Dict[TestSection, Callable] |
| 51 | + |
| 52 | + |
| 53 | +TESTS = [ |
| 54 | + ( |
| 55 | + TestSection.CONNECTIVITY, |
| 56 | + test_connectivity.run, |
| 57 | + ), |
| 58 | + ( |
| 59 | + TestSection.Z_AXIS_BASIC, |
| 60 | + test_z_axis_basic.run, |
| 61 | + ), |
| 62 | + ( |
| 63 | + TestSection.X_AXIS_BASIC, |
| 64 | + test_x_axis_basic.run, |
| 65 | + ), |
| 66 | + ( |
| 67 | + TestSection.L_AXIS_BASIC, |
| 68 | + test_l_axis_basic.run, |
| 69 | + ), |
| 70 | + ( |
| 71 | + TestSection.STALLGUARD, |
| 72 | + test_stallguard.run, |
| 73 | + ), |
| 74 | + ( |
| 75 | + TestSection.ESTOP, |
| 76 | + test_estop.run, |
| 77 | + ), |
| 78 | + ( |
| 79 | + TestSection.DOOR_SWITCH, |
| 80 | + test_door_switch.run, |
| 81 | + ), |
| 82 | + ( |
| 83 | + TestSection.UI_LEDS, |
| 84 | + test_ui_leds.run, |
| 85 | + ), |
| 86 | + ( |
| 87 | + TestSection.UV_LOCKOUT_SWITCH, |
| 88 | + test_uv_lockout_switch.run, |
| 89 | + ), |
| 90 | + ( |
| 91 | + TestSection.INSTALL_DETECTION, |
| 92 | + test_install_detection.run, |
| 93 | + ), |
| 94 | + ( |
| 95 | + TestSection.TOF_BASIC, |
| 96 | + test_tof_basic.run, |
| 97 | + ), |
| 98 | + ( |
| 99 | + TestSection.TOF_FUNCTIONAL, |
| 100 | + test_tof_functional.run, |
| 101 | + ), |
| 102 | + ( |
| 103 | + TestSection.Z_AXIS_CURRENT_SPEED, |
| 104 | + test_z_axis_current_speed.run, |
| 105 | + ), |
| 106 | + ( |
| 107 | + TestSection.X_AXIS_CURRENT_SPEED, |
| 108 | + test_x_axis_current_speed.run, |
| 109 | + ), |
| 110 | +] |
| 111 | + |
| 112 | + |
| 113 | +def build_report(test_name: str) -> CSVReport: |
| 114 | + """Build report.""" |
| 115 | + return CSVReport( |
| 116 | + test_name=test_name, |
| 117 | + sections=[ |
| 118 | + CSVSection( |
| 119 | + title=TestSection.CONNECTIVITY.value, |
| 120 | + lines=test_connectivity.build_csv_lines(), |
| 121 | + ), |
| 122 | + CSVSection( |
| 123 | + title=TestSection.ESTOP.value, |
| 124 | + lines=test_estop.build_csv_lines(), |
| 125 | + ), |
| 126 | + CSVSection( |
| 127 | + title=TestSection.DOOR_SWITCH.value, |
| 128 | + lines=test_door_switch.build_csv_lines(), |
| 129 | + ), |
| 130 | + CSVSection( |
| 131 | + title=TestSection.Z_AXIS_BASIC.value, |
| 132 | + lines=test_z_axis_basic.build_csv_lines(), |
| 133 | + ), |
| 134 | + CSVSection( |
| 135 | + title=TestSection.X_AXIS_BASIC.value, |
| 136 | + lines=test_x_axis_basic.build_csv_lines(), |
| 137 | + ), |
| 138 | + CSVSection( |
| 139 | + title=TestSection.L_AXIS_BASIC.value, |
| 140 | + lines=test_l_axis_basic.build_csv_lines(), |
| 141 | + ), |
| 142 | + CSVSection( |
| 143 | + title=TestSection.STALLGUARD.value, |
| 144 | + lines=test_stallguard.build_csv_lines(), |
| 145 | + ), |
| 146 | + CSVSection( |
| 147 | + title=TestSection.UI_LEDS.value, |
| 148 | + lines=test_ui_leds.build_csv_lines(), |
| 149 | + ), |
| 150 | + CSVSection( |
| 151 | + title=TestSection.UV_LOCKOUT_SWITCH.value, |
| 152 | + lines=test_uv_lockout_switch.build_csv_lines(), |
| 153 | + ), |
| 154 | + CSVSection( |
| 155 | + title=TestSection.INSTALL_DETECTION.value, |
| 156 | + lines=test_install_detection.build_csv_lines(), |
| 157 | + ), |
| 158 | + CSVSection( |
| 159 | + title=TestSection.TOF_BASIC.value, |
| 160 | + lines=test_tof_basic.build_csv_lines(), |
| 161 | + ), |
| 162 | + CSVSection( |
| 163 | + title=TestSection.TOF_FUNCTIONAL.value, |
| 164 | + lines=test_tof_functional.build_csv_lines(), |
| 165 | + ), |
| 166 | + CSVSection( |
| 167 | + title=TestSection.Z_AXIS_CURRENT_SPEED.value, |
| 168 | + lines=test_z_axis_current_speed.build_csv_lines(), |
| 169 | + ), |
| 170 | + CSVSection( |
| 171 | + title=TestSection.X_AXIS_CURRENT_SPEED.value, |
| 172 | + lines=test_x_axis_current_speed.build_csv_lines(), |
| 173 | + ), |
| 174 | + ], |
| 175 | + ) |
0 commit comments