def test_directive_match_false_true(data): directive = [ { 'match': {'name': "TEAST_CASE\\d+", "valueGt": 7}, 'action': {'sink': 'tester1', 'state': 'off', 'ch': 1} }] parsed = parse_directive(directive) combined_functor = list(parsed.keys())[0] assert combined_functor(data) is False
def test_directive_action(data): directive = [ { 'match': {'name': "TEAST_CASE\\d+", "valueGt": 7}, 'action': {'sink': 'tester1', 'state': 'off', 'ch': 1} }] controllers = { 'tester1': Test.TestSink('localhost', '45679') } parsed = parse_directive(directive) executor = list(parsed.values())[0] assert executor(controllers) == 'http://localhost:45679/test/1/off'
######### # Setup # ######### args = parse_input() options = parse_config(args.configFile) logging_queue = Queue() logging_thread = LoggingThread(logging_queue, **options['log']) sensors = SensorEmitter(options['sensors']) sensors.init_sensors() controllers = emit_controller(options['controllers']) ctrl_rules = parse_directive(options['ctrlRules']) client = CtrlClient(sensors.queue.async_q, sensors.stop_event, sensors.emitted_sensors, controllers=controllers, ctrlRules=ctrl_rules, **options['client']) if __name__ == "__main__": logging_thread.start() sensors.start() client.run() logging_thread.stop() turn_off_usb_relay()