added test for 'clean' argument passed to 'start_polling()' - #2002
Conversation
Bibo-Joshi
left a comment
There was a problem hiding this comment.
Hi. Thanks for the PR.
TBH, I don't really understand, what's going on. IISC, What we would want to test is
- On the first call of
get_updates(), that returns a list of updates with ids - Make sure that for every such id
i,get_updates()is called withoffset=i
I don't really get, how self.update_id achieves that and what the "infinity loop protection" does … Could you try to make the code more intuitive to read? Descriptive namings and precise comments are helpful for that ;)
Trying to test clean. Clean will cause all updates to be ignored. It does that by getting all updates and than calling get_updates() with the highest update_id. This results in all updates with a lower id to be discarded.
I mocked get_updates() to return a list of fake updates when called the 1 first time. The second time it's called we will pass an in update_id from the bootstrap ____clean function. We want to know what id that is and verify it's the 'highest'.
bootstrap___clean doesn't behave like this. It just assumes that the updates are chronological and takes update_id from the last item in the list.
My logic is that if we pass 3 id's, and we know the highest id = 3 than we can validate clean by checking which update_id it will call get_updates() with the second time. inf loop protection is something left over from debugging If get_updates() behaviour changes, it won't be caught with this test. if we want to test for that we shouldn't mock get_updates().
10-4 |
This reverts commit 4566a1d.
…nt offset (which is the update_id)
Bibo-Joshi
left a comment
There was a problem hiding this comment.
Thanks for clarifying! Got it now and the test is looking much better :)
Two minor comments, though.
This reverts commit 1fb498a.
|
Thank you for your contribution :) |
Looking for feedback, first attempt at this.
Kinda feels wrong to raise an error to jump out of the 'update' def when there is success.