Skip to content

Add migrate_chat_data method to dispatcher #2848

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Jan 19, 2022
Merged

Add migrate_chat_data method to dispatcher #2848

merged 20 commits into from
Jan 19, 2022

Conversation

DonalDuck004
Copy link
Contributor

@Bibo-Joshi now there should be no problem, do I have to create a unit_test next?

Copy link
Member

@Bibo-Joshi Bibo-Joshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the RP! The code looks good overall - my comments are largely nitpicks :)

Yes, we will need unit tests. You can place them into tests/test_dispatcher.py. Please be sure that the tests cover all cases, e.g. passing a message without migration data, passing both message & old/new_chat_id etc …
The contribution guide has info on how to run the tests locally.
At the bottom of this PR you see the results of the test suite - the "codecov" results tell you if you have covered all changed lines in your unit tests.

Additionally, the pre-commit test failed. Please be sure to install the pre-commit hooks as described in the contrib guide. you can also run them manually with pre-commit run after git add -ing your changes.

DonalDuck004 and others added 5 commits January 7, 2022 14:58
Co-authored-by: Bibo-Joshi <22366557+Bibo-Joshi@users.noreply.github.com>
Co-authored-by: Bibo-Joshi <22366557+Bibo-Joshi@users.noreply.github.com>
Co-authored-by: Bibo-Joshi <22366557+Bibo-Joshi@users.noreply.github.com>
Co-authored-by: Bibo-Joshi <22366557+Bibo-Joshi@users.noreply.github.com>
@DonalDuck004
Copy link
Contributor Author

Thanks for the RP! The code looks good overall - my comments are largely nitpicks :)

Yes, we will need unit tests. You can place them into tests/test_dispatcher.py. Please be sure that the tests cover all cases, e.g. passing a message without migration data, passing both message & old/new_chat_id etc … The contribution guide has info on how to run the tests locally. At the bottom of this PR you see the results of the test suite - the "codecov" results tell you if you have covered all changed lines in your unit tests.

Additionally, the pre-commit test failed. Please be sure to install the pre-commit hooks as described in the contrib guide. you can also run them manually with pre-commit run after git add -ing your changes.

Ok, I'll try tonight/tomorrow

@DonalDuck004
Copy link
Contributor Author

Thanks for the RP! The code looks good overall - my comments are largely nitpicks :)

Yes, we will need unit tests. You can place them into tests/test_dispatcher.py. Please be sure that the tests cover all cases, e.g. passing a message without migration data, passing both message & old/new_chat_id etc … The contribution guide has info on how to run the tests locally. At the bottom of this PR you see the results of the test suite - the "codecov" results tell you if you have covered all changed lines in your unit tests.

Additionally, the pre-commit test failed. Please be sure to install the pre-commit hooks as described in the contrib guide. you can also run them manually with pre-commit run after git add -ing your changes.

Both my test aren't written correctly, but I haven't in mind any other way to make it, can you help me? :/

Copy link
Member

@Bibo-Joshi Bibo-Joshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, what the tests should do is:

  1. Store some data in dispatcher.chat_data[some_id]
  2. pass arguments to migrate_chat_data
  3. if you expect that to raise an exception, check that it was raised
  4. otherwise, check that dispatcher.chat_data was adjusted as expected

Maybe this helps a bit. Also, here you can see which lines are not covered by the tests.

Feel free to ping me in https://t.me/pythontelegrambotdev, if you have any question :) (@BiboJoshi on TG)

@DonalDuck004
Copy link
Contributor Author

In general, what the tests should do is:

  1. Store some data in dispatcher.chat_data[some_id]
  2. pass arguments to migrate_chat_data
  3. if you expect that to raise an exception, check that it was raised
  4. otherwise, check that dispatcher.chat_data was adjusted as expected

Maybe this helps a bit. Also, here you can see which lines are not covered by the tests.

Feel free to ping me in https://t.me/pythontelegrambotdev, if you have any question :) (@BiboJoshi on TG)

Thanks, for your time and help, now all tests pass except deep source, but I haven't changed any of the reported files, what should I do?

Copy link
Member

@Bibo-Joshi Bibo-Joshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates! LGTM except for my minor comments below :)
@Poolitzer, could you give it a second review?

DeepSource is currently reporting some false positives. I have already reported them, but they haven't updated it yet. We can ignore that for now.

Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
@harshil21 harshil21 added this to the v14 milestone Jan 10, 2022
@Bibo-Joshi Bibo-Joshi requested a review from Poolitzer January 11, 2022 07:07
Copy link
Member

@Poolitzer Poolitzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good.

@Bibo-Joshi
Copy link
Member

I updated the PR according to #2852 and added an additional test. merging.
Thanks @DonalDuck004 for the nice contribution 👍

@Bibo-Joshi Bibo-Joshi merged commit 8faaa27 into python-telegram-bot:v14 Jan 19, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jan 27, 2022
@Bibo-Joshi Bibo-Joshi added 🔌 enhancement pr description: enhancement and removed enhancement labels Nov 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🔌 enhancement pr description: enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants