{"action":"created","issue":{"url":"https://api.github.com/repos/getsentry/responses/issues/99","repository_url":"https://api.github.com/repos/getsentry/responses","labels_url":"https://api.github.com/repos/getsentry/responses/issues/99/labels{/name}","comments_url":"https://api.github.com/repos/getsentry/responses/issues/99/comments","events_url":"https://api.github.com/repos/getsentry/responses/issues/99/events","html_url":"https://github.com/getsentry/responses/issues/99","id":129077130,"number":99,"title":"Feature request: response depending on invocation index","user":{"login":"marekyggdrasil","id":8202674,"avatar_url":"https://avatars.githubusercontent.com/u/8202674?v=3","gravatar_id":"","url":"https://api.github.com/users/marekyggdrasil","html_url":"https://github.com/marekyggdrasil","followers_url":"https://api.github.com/users/marekyggdrasil/followers","following_url":"https://api.github.com/users/marekyggdrasil/following{/other_user}","gists_url":"https://api.github.com/users/marekyggdrasil/gists{/gist_id}","starred_url":"https://api.github.com/users/marekyggdrasil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marekyggdrasil/subscriptions","organizations_url":"https://api.github.com/users/marekyggdrasil/orgs","repos_url":"https://api.github.com/users/marekyggdrasil/repos","events_url":"https://api.github.com/users/marekyggdrasil/events{/privacy}","received_events_url":"https://api.github.com/users/marekyggdrasil/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-01-27T09:03:30Z","updated_at":"2016-07-05T00:55:44Z","closed_at":null,"body":"It could be interesting to be able to program different response at second, third, fourth.. call such as:\r\n```python\r\nresponses.add(responses.GET, 'http://twitter.com/api/1/foobar', json={\"msg\": \"not found\"}, status=404)\r\nresponses.add(responses.GET, 'http://twitter.com/api/1/foobar', json={\"msg\": \"OK\"}, status=200)\r\nresponses.add(responses.GET, 'http://twitter.com/api/1/foobar', json={\"msg\": \"OK\"}, status=200)\r\nresponses.add(responses.GET, 'http://twitter.com/api/1/foobar', json={\"msg\": \"not found\"}, status=404)\r\nprint requests.get('http://twitter.com/api/1/foobar')\r\nprint requests.get('http://twitter.com/api/1/foobar')\r\nprint requests.get('http://twitter.com/api/1/foobar')\r\nprint requests.get('http://twitter.com/api/1/foobar')\r\n```\r\n\r\nExpected standard output:\r\n\r\n```\r\n<Response [404]>\r\n<Response [200]>\r\n<Response [200]>\r\n<Response [404]>\r\n```\r\n\r\nExplanation: If we add response to same URL we simply specify the next response.\r\n\r\nJust like it is done in PHP using PHPUnit, provided with [that](https://phpunit.de/manual/current/en/test-doubles.html)\r\n\r\nRefer to `Table 9.1. Matchers`, quoting \r\n\r\n<img width=\"1230\" alt=\"screen shot 2016-01-27 at 4 52 21 pm\" src=\"https://cloud.githubusercontent.com/assets/8202674/12608305/5e6c6b34-c516-11e5-999f-4ac5735fc024.png\">\r\n\r\nFor not the only way I see to reproduce such behaviour is using callback with counter which is a global variable, and it doesn't seem to be elegant way to do it.\r\n\r\n```python\r\nglobal call\r\n\r\n@responses.activate\r\ndef test():\r\n    global call\r\n    call = 0\r\n    def request_callback(request):\r\n        global call\r\n        headers = {'key': 'value'}\r\n        if call == 0 :\r\n            call = 1\r\n            return (404, headers, '{\"msg\": \"not found\"}')\r\n        elif call == 1 :\r\n            call = 0\r\n            return (200, headers, '{\"msg\": \"ok\"}')\r\n    responses.add_callback(responses.GET, 'http://twitter.com/api/1/foobar', callback=request_callback)\r\n    print requests.get('http://twitter.com/api/1/foobar')\r\n    print requests.get('http://twitter.com/api/1/foobar')\r\n```"},"comment":{"url":"https://api.github.com/repos/getsentry/responses/issues/comments/230367971","html_url":"https://github.com/getsentry/responses/issues/99#issuecomment-230367971","issue_url":"https://api.github.com/repos/getsentry/responses/issues/99","id":230367971,"user":{"login":"jclark360","id":6331228,"avatar_url":"https://avatars.githubusercontent.com/u/6331228?v=3","gravatar_id":"","url":"https://api.github.com/users/jclark360","html_url":"https://github.com/jclark360","followers_url":"https://api.github.com/users/jclark360/followers","following_url":"https://api.github.com/users/jclark360/following{/other_user}","gists_url":"https://api.github.com/users/jclark360/gists{/gist_id}","starred_url":"https://api.github.com/users/jclark360/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jclark360/subscriptions","organizations_url":"https://api.github.com/users/jclark360/orgs","repos_url":"https://api.github.com/users/jclark360/repos","events_url":"https://api.github.com/users/jclark360/events{/privacy}","received_events_url":"https://api.github.com/users/jclark360/received_events","type":"User","site_admin":false},"created_at":"2016-07-05T00:55:43Z","updated_at":"2016-07-05T00:55:43Z","body":"👍  same here."}}
{"actor":{"display_login":"jclark360"}}