def on_post(self, req, resp, validated_body): """ receives json req to register worker responds with a 202 for success """ #load json payload in body body = validated_body['worker_registration'] #instantiate new worker object new_worker = Worker(**body) #persist the new worker coordinator_flow.add_worker(self.db, new_worker) resp.status = falcon.HTTP_202 resp.body = format_response_body( {'worker_identity': new_worker.get_registration_identity()})
def test_add_worker(self): db_handler = MagicMock() db_handler.put.return_value = self.worker.format() coordinator_flow.add_worker(db_handler, self.worker_id)