{"action":"created","issue":{"url":"https://api.github.com/repos/locustio/locust/issues/879","repository_url":"https://api.github.com/repos/locustio/locust","labels_url":"https://api.github.com/repos/locustio/locust/issues/879/labels{/name}","comments_url":"https://api.github.com/repos/locustio/locust/issues/879/comments","events_url":"https://api.github.com/repos/locustio/locust/issues/879/events","html_url":"https://github.com/locustio/locust/issues/879","id":359022866,"node_id":"MDU6SXNzdWUzNTkwMjI4NjY=","number":879,"title":"Request template","user":{"login":"siyu6974","id":15876323,"node_id":"MDQ6VXNlcjE1ODc2MzIz","avatar_url":"https://avatars1.githubusercontent.com/u/15876323?v=4","gravatar_id":"","url":"https://api.github.com/users/siyu6974","html_url":"https://github.com/siyu6974","followers_url":"https://api.github.com/users/siyu6974/followers","following_url":"https://api.github.com/users/siyu6974/following{/other_user}","gists_url":"https://api.github.com/users/siyu6974/gists{/gist_id}","starred_url":"https://api.github.com/users/siyu6974/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/siyu6974/subscriptions","organizations_url":"https://api.github.com/users/siyu6974/orgs","repos_url":"https://api.github.com/users/siyu6974/repos","events_url":"https://api.github.com/users/siyu6974/events{/privacy}","received_events_url":"https://api.github.com/users/siyu6974/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-09-11T12:24:59Z","updated_at":"2018-09-12T07:59:32Z","closed_at":null,"author_association":"NONE","body":"### Description of feature request\r\nIt would be nice to have a template system to generate request data. For example, generating username, email...\r\n\r\n### Expected behavior\r\nStore request templates in _template_/, load it by file name.\r\n\r\n```   \r\n# locustfile.py\r\ndef register(self):\r\n    self.client.post(\"/api/users\", newUserObject())\r\n\r\n# template.py\r\ndef newUserObject():\r\n    usr = randomString()\r\n    params = {\"username\": usr,\r\n              \"email\": usr+\"@test.com\"}\r\n    return makeRequestJson(\"createUserTemplate\", params)\r\n```\r\nI already build such a system for my test, I can do a PR if needed."},"comment":{"url":"https://api.github.com/repos/locustio/locust/issues/comments/420550853","html_url":"https://github.com/locustio/locust/issues/879#issuecomment-420550853","issue_url":"https://api.github.com/repos/locustio/locust/issues/879","id":420550853,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMDU1MDg1Mw==","user":{"login":"siyu6974","id":15876323,"node_id":"MDQ6VXNlcjE1ODc2MzIz","avatar_url":"https://avatars1.githubusercontent.com/u/15876323?v=4","gravatar_id":"","url":"https://api.github.com/users/siyu6974","html_url":"https://github.com/siyu6974","followers_url":"https://api.github.com/users/siyu6974/followers","following_url":"https://api.github.com/users/siyu6974/following{/other_user}","gists_url":"https://api.github.com/users/siyu6974/gists{/gist_id}","starred_url":"https://api.github.com/users/siyu6974/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/siyu6974/subscriptions","organizations_url":"https://api.github.com/users/siyu6974/orgs","repos_url":"https://api.github.com/users/siyu6974/repos","events_url":"https://api.github.com/users/siyu6974/events{/privacy}","received_events_url":"https://api.github.com/users/siyu6974/received_events","type":"User","site_admin":false},"created_at":"2018-09-12T07:59:32Z","updated_at":"2018-09-12T07:59:32Z","author_association":"NONE","body":"The goal is to make the locustfile.py more compact. It offloads content creation to another file.\r\nFor example, to create a user object, we would have to \r\n```\r\n# locustfile.py\r\ndef register(self):\r\n    usr = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(5))\r\n    pwd = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(5))\r\n    user = {\"\"username\": usr,\r\n              \"email\": usr+\"@test.com\"\"\r\n              \"password\": pwd}\r\n    self.client.post(\"/api/users\", user)\r\n```\r\nThings can get even messier if there are more fields.\r\nWhat I propose is to have a folder storing templates files, like\r\n```\r\n/templates\r\n    newUser.json\r\n    newOrganisation.json\r\n```\r\nThese templates file are just normal json with placeholder value, which can be easily acquired with a swagger or api explorer.\r\n"}}
{"actor":{"display_login":"siyu6974"}}