{"action":"created","issue":{"url":"https://api.github.com/repos/algolia/algoliasearch-django/issues/249","repository_url":"https://api.github.com/repos/algolia/algoliasearch-django","labels_url":"https://api.github.com/repos/algolia/algoliasearch-django/issues/249/labels{/name}","comments_url":"https://api.github.com/repos/algolia/algoliasearch-django/issues/249/comments","events_url":"https://api.github.com/repos/algolia/algoliasearch-django/issues/249/events","html_url":"https://github.com/algolia/algoliasearch-django/issues/249","id":309442953,"node_id":"MDU6SXNzdWUzMDk0NDI5NTM=","number":249,"title":"Faster tests by using wait_task","user":{"login":"PLNech","id":1821404,"node_id":"MDQ6VXNlcjE4MjE0MDQ=","avatar_url":"https://avatars0.githubusercontent.com/u/1821404?v=4","gravatar_id":"","url":"https://api.github.com/users/PLNech","html_url":"https://github.com/PLNech","followers_url":"https://api.github.com/users/PLNech/followers","following_url":"https://api.github.com/users/PLNech/following{/other_user}","gists_url":"https://api.github.com/users/PLNech/gists{/gist_id}","starred_url":"https://api.github.com/users/PLNech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PLNech/subscriptions","organizations_url":"https://api.github.com/users/PLNech/orgs","repos_url":"https://api.github.com/users/PLNech/repos","events_url":"https://api.github.com/users/PLNech/events{/privacy}","received_events_url":"https://api.github.com/users/PLNech/received_events","type":"User","site_admin":false},"labels":[{"id":860625893,"node_id":"MDU6TGFiZWw4NjA2MjU4OTM=","url":"https://api.github.com/repos/algolia/algoliasearch-django/labels/Enhancement","name":"Enhancement","color":"3369e6","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-03-28T16:36:14Z","updated_at":"2018-06-19T05:57:18Z","closed_at":null,"author_association":"MEMBER","body":"Today, several of our tests are slowed down by forced sleeping:\r\n\r\n```python\r\ndef test_save_signal(self):\r\n        Website.objects.create(name='Algolia', url='https://www.algolia.com')\r\n        Website.objects.create(name='Google', url='https://www.google.com')\r\n        Website.objects.create(name='Facebook', url='https://www.facebook.com')\r\n\r\n        time.sleep(10)  # FIXME: Expose last task's ID so we can waitTask instead of sleeping\r\n        self.assertEqual(raw_search(Website)['nbHits'], 3)\r\n``` \r\n\r\nWe could replace the `sleep` call by leveraging [`wait_task`](https://www.algolia.com/doc/api-reference/api-methods/wait-task/). This requires:\r\n- [x] exposing it on the Client and not only on the index, see PR algolia/algoliasearch-client-python#343\r\n- [ ] facading it in `AlgoliaEngine`\r\n- [ ] Because the taskID is returned in the `__post_save_receiver` hook, we need to expose the last taskID somewhere like `AlgoliaEngine.last_taskID` so you can then refactor the previous code as:\r\n```python\r\ndef test_save_signal(self):\r\n        Website.objects.create(name='Algolia', url='https://www.algolia.com')\r\n        Website.objects.create(name='Google', url='https://www.google.com')\r\n        Website.objects.create(name='Facebook', url='https://www.facebook.com')\r\n\r\n        algolia_engine.wait_task(algolia_engine.last_taskID)\r\n        self.assertEqual(raw_search(Website)['nbHits'], 3)\r\n``` "},"comment":{"url":"https://api.github.com/repos/algolia/algoliasearch-django/issues/comments/398283059","html_url":"https://github.com/algolia/algoliasearch-django/issues/249#issuecomment-398283059","issue_url":"https://api.github.com/repos/algolia/algoliasearch-django/issues/249","id":398283059,"node_id":"MDEyOklzc3VlQ29tbWVudDM5ODI4MzA1OQ==","user":{"login":"julienbourdeau","id":1525636,"node_id":"MDQ6VXNlcjE1MjU2MzY=","avatar_url":"https://avatars1.githubusercontent.com/u/1525636?v=4","gravatar_id":"","url":"https://api.github.com/users/julienbourdeau","html_url":"https://github.com/julienbourdeau","followers_url":"https://api.github.com/users/julienbourdeau/followers","following_url":"https://api.github.com/users/julienbourdeau/following{/other_user}","gists_url":"https://api.github.com/users/julienbourdeau/gists{/gist_id}","starred_url":"https://api.github.com/users/julienbourdeau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/julienbourdeau/subscriptions","organizations_url":"https://api.github.com/users/julienbourdeau/orgs","repos_url":"https://api.github.com/users/julienbourdeau/repos","events_url":"https://api.github.com/users/julienbourdeau/events{/privacy}","received_events_url":"https://api.github.com/users/julienbourdeau/received_events","type":"User","site_admin":false},"created_at":"2018-06-19T05:57:18Z","updated_at":"2018-06-19T05:57:18Z","author_association":"CONTRIBUTOR","body":"`wait_task` is now exposed on the client, but note that you need to pass the index name along with th taskID. See commit here: https://github.com/algolia/algoliasearch-client-python/pull/373/commits/88f9b98c9b4d5b383f0f138a2a8d74cf0b23d8b6\r\n"}}
{"actor":{"display_login":"julienbourdeau"}}