-
Notifications
You must be signed in to change notification settings - Fork 6k
feat: add Defaults.business_connection_id support #5097
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
base: master
Are you sure you want to change the base?
feat: add Defaults.business_connection_id support #5097
Conversation
- Add business_connection_id parameter to Defaults class - Update all send_* methods to use ODVInput[str] for business_connection_id - This allows setting a default business_connection_id via Defaults mechanism - Follows the same pattern as other defaults like parse_mode and disable_notification Closes python-telegram-bot#4193
- Use DefaultValue.get_value() to extract str | None from ODVInput[str] - Fixes type incompatibility when assigning business_connection_id
|
hello @Bibo-Joshi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi. Thanks for your PR.
The changes look ok at first glance. However, we'll need unit tests for all modified bot methods ensuring that the defaults values are passed correctly. Please have a look at e.g.
python-telegram-bot/tests/test_bot.py
Lines 2500 to 2523 in 8511941
| @pytest.mark.parametrize("default_bot", [{"parse_mode": "Markdown"}], indirect=True) | |
| @pytest.mark.parametrize( | |
| ("passed_value", "expected_value"), | |
| [(DEFAULT_NONE, "Markdown"), ("HTML", "HTML"), (None, None)], | |
| ) | |
| async def test_gift_premium_subscription_default_parse_mode( | |
| self, default_bot, monkeypatch, passed_value, expected_value | |
| ): | |
| # can't make actual request so we just test that the correct data is passed | |
| async def make_assertion(url, request_data, *args, **kwargs): | |
| assert request_data.parameters.get("text_parse_mode") == expected_value | |
| return True | |
| monkeypatch.setattr(default_bot.request, "post", make_assertion) | |
| kwargs = { | |
| "user_id": 123, | |
| "month_count": 3, | |
| "star_count": 1000, | |
| "text": "text", | |
| } | |
| if passed_value is not DEFAULT_NONE: | |
| kwargs["text_parse_mode"] = passed_value | |
| assert await default_bot.gift_premium_subscription(**kwargs) |
or one of the many other test_*_default_* tests on how they use parametrization for the tests.
Moreover, I'll to put this on hault hold until after #5078 is merged since Bot API 9.3 adds new methods with business_connection_id parameters.
- Replace hardcoded version number with NEXT.VERSION placeholder - Follows project standard for version documentation
sounds fair, please ping me when you merge #5078 |
|
@Francluob you can subscribe to the PR, then you'll be notified :) |
Closes #4193
Contribution by Gittensor, see my contribution statistics at https://gittensor.io/miners/details?githubId=11581451