Index: tests/peter/test_gen_requirements.py =================================================================== diff -u -r8a3a1047368db91a54399f3d0d30548fe55c222d -rbc228b037aaa5c57d49aee9658f6083036885415 --- tests/peter/test_gen_requirements.py (.../test_gen_requirements.py) (revision 8a3a1047368db91a54399f3d0d30548fe55c222d) +++ tests/peter/test_gen_requirements.py (.../test_gen_requirements.py) (revision bc228b037aaa5c57d49aee9658f6083036885415) @@ -14,149 +14,141 @@ # ############################################################################ import sys + sys.path.append("../../") + from dialin.dg.dialysate_generator import DG from dialin.hd.hemodialysis_device import HD -from typing import List -def gen_publish_requirements(modules: List[object]) -> dict: +def gen_publish_requirements(module) -> dict: """ Generates a list of publish requirements - @param modules: + @param module: the module to generate publish requirements for @return: """ result = {} - for module in modules: - for attr in dir(module): - if not callable(getattr(module, attr)) and \ - not attr.startswith("MSG") and \ - not attr.startswith("START") and \ - not attr.startswith("END") and \ - not attr == "can_interface" and \ - not attr.startswith("_") and \ - not attr.isupper(): - result[module.__class__.__name__] = result.get(module.__class__.__name__, []) + [attr] + for attr in dir(module): + if not callable(getattr(module, attr)) and \ + not attr.startswith("MSG") and \ + not attr.startswith("START") and \ + not attr.startswith("END") and \ + not attr == "can_interface" and \ + not attr == "logger" and \ + not attr.startswith("_") and \ + not attr.isupper(): + result[module.__class__.__name__] = result.get(module.__class__.__name__, []) + [attr] - for module, attrs in result.items(): - print("\n{0} \n ".format(module)) + for _, attrs in result.items(): for attr in attrs: - print("The Dialin API shall publish the {0} to all observers upon HD messaging.".format(attr.replace("_", " "))) + print("The Dialin API shall publish the {0} to all observers upon HD messaging.".format( + attr.replace("_", " "))) return result -def gen_cmd_requirements(modules: List[object]) -> dict: +def gen_cmd_requirements(module) -> dict: """ Generates requirements from dialin commands - @param modules: the list of modules to generate requirements for + @param module: the module to generate command requirements for @return: """ result = {} - for module in modules: - for attr in dir(module): - if callable(getattr(module, attr)) and attr.startswith("cmd"): - result[module.__class__.__name__] = result.get(module.__class__.__name__, []) + [attr] + for attr in dir(module): + if callable(getattr(module, attr)) and attr.startswith("cmd"): + result[module.__class__.__name__] = result.get(module.__class__.__name__, []) + [attr] - for module, attrs in result.items(): - print("\n{0} \n ".format(module)) + for _, attrs in result.items(): for attr in attrs: - print("The Dialin API shall provide a command that constructs and sends the {0} command.".format(attr - .replace("_", " ") - .replace("cmd ", "") - .replace("uf", "UF") - .replace("ui", "UI") - )) + print("The Dialin API shall provide a command that constructs and sends the {0} command.".format( + attr.replace("_uf_", "_UF_") + .replace("_ui_", "_UI_") + .replace("cmd_", "") + .replace("_", " ") + )) return result -def generate_hd_requirements(): - """ - Generates requires for the HD +hd = HD() +dg = DG() - @return: None - """ - hd = HD() +hd_modules = [ + hd, + hd.accel, + hd.air_bubbles, + hd.air_trap, + hd.alarms, + hd.bloodflow, + hd.blood_leak, + hd.buttons, + hd.calibration_record, + hd.dialysate_inlet_flow, + hd.dialysate_outlet_flow, + hd.fluid_leak, + hd.pressure_occlusion, + hd.pretreatment, + hd.rtc, + hd.service_record, + hd.switches, + hd.syringe_pump, + hd.system_record, + hd.treatment, + hd.ui, + hd.valves, + hd.voltages, + hd.watchdog, +] - modules = [ - hd, - hd.accel, - hd.air_bubbles, - hd.air_trap, - hd.alarms, - hd.blood_leak, - hd.bloodflow, - hd.buttons, - hd.calibration_record, - hd.dialysate_inlet_flow, - hd.dialysate_outlet_flow, - hd.fluid_leak, - hd.pressure_occlusion, - hd.pretreatment, - hd.rtc, - hd.service_record, - hd.switches, - hd.syringe_pump, - hd.system_record, - hd.treatment, - hd.ui, - hd.valves, - hd.voltages, - hd.watchdog, - ] - gen_publish_requirements(modules) - gen_cmd_requirements(modules) +dg_modules = [ + dg, + dg.accel, + dg.alarms, + dg.calibration_record, + dg.chemical_disinfect, + dg.concentrate_pumps, + dg.conductivity_sensors, + dg.drain_pump, + dg.fans, + dg.fluid_leak, + dg.flush, + dg.hd_proxy, + dg.heat_disinfect, + dg.heaters, + dg.load_cells, + dg.pressures, + dg.reservoirs, + dg.ro_pump, + dg.rtc, + dg.samplewater, + dg.scheduled_runs_record, + dg.service_record, + dg.switches, + dg.system_record, + dg.temperature_sensors, + dg.thermistors, + dg.uv_reactors, + dg.valves, + dg.voltages, +] -def generate_dg_requirements(): +def generate_requirements(modules): """ - Generates requires for the DG + Generates requirements for given modules + @param modules: the modules to generate requirements for @return: None """ + for module in modules: + print("\n{0}\n".format(module.__class__.__name__)) + gen_publish_requirements(module) + gen_cmd_requirements(module) - dg = DG() - modules = [ - dg, - dg.accel, - dg.alarms, - dg.calibration_record, - dg.chemical_disinfect, - dg.concentrate_pumps, - dg.conductivity_sensors, - dg.drain_pump, - dg.fans, - dg.fluid_leak, - dg.flush, - dg.hd_proxy, - dg.heat_disinfect, - dg.heaters, - dg.load_cells, - dg.pressures, - dg.reservoirs, - dg.ro_pump, - dg.rtc, - dg.samplewater, - dg.scheduled_runs_record, - dg.service_record, - dg.switches, - dg.system_record, - dg.temperature_sensors, - dg.thermistors, - dg.uv_reactors, - dg.valves, - dg.voltages, - ] - - gen_publish_requirements(modules) - gen_cmd_requirements(modules) - - if __name__ == '__main__': - generate_dg_requirements() - generate_hd_requirements() + generate_requirements(hd_modules) + generate_requirements(dg_modules)