'status': { 'data': ret['data'], 'responseType': ret['responseType'] } } return make_response(json.dumps(resp_obj), 200) if __name__ == '__main__': while True: try: # execute the EJBCA handshake and load SOAP API metadata initicalConf() break except requests.exceptions.RequestException: print("Cant connect to EJBCA server for initial configuration") print("Chances are the server is not ready yet.") print("Will retry in 30sec") sleep(30) # Configure and initalize the messenger config = Config() messenger = Messenger("ejbca-rest", config) messenger.init() # Subscribe to devices topics and register callback to process new events messenger.create_channel(config.dojot['subjects']['devices'], "r") messenger.on(config.dojot['subjects']['devices'], "message", receiver_kafka) # Gets all devices that are already active on dojot messenger.generate_device_create_event_for_active_devices() app.run(host='0.0.0.0', port=5583, threaded=True)
def test_messenger_generate_device_events(): mock_self = Mock(tenants=["tenant-1", "tenant-2"], request_device=Mock()) Messenger.generate_device_create_event_for_active_devices(mock_self) mock_self.request_device.assert_any_call("tenant-1") mock_self.request_device.assert_any_call("tenant-2")