Skip to content

Conversation

@Francluob
Copy link

  • 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 #4193

Contribution by Gittensor, see my contribution statistics at https://gittensor.io/miners/details?githubId=11581451

- 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
@Francluob
Copy link
Author

hello @Bibo-Joshi
could you please review my pr?
thanks

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.

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.

@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
@Francluob
Copy link
Author

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.

@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 until after #5078 is merged since Bot API 9.3 adds new methods with business_connection_id parameters.

sounds fair, please ping me when you merge #5078

@Bibo-Joshi
Copy link
Member

@Francluob you can subscribe to the PR, then you'll be notified :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Defaults.business_connection_id

2 participants