Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@Bibo-Joshi
Copy link
Member

closes #4578

A Release containing this feature should update https://github.com/python-telegram-bot/python-telegram-bot/wiki/Avoiding-flood-limits accordingly

@Bibo-Joshi Bibo-Joshi added ℹ️ needs-wiki-update information: needs-wiki-update 🔌 enhancement pr description: enhancement labels Dec 31, 2024
@codecov
Copy link

codecov bot commented Dec 31, 2024

❌ 3 Tests Failed:

Tests completed Failed Passed Skipped
6572 3 6569 699
View the top 3 failed tests by shortest run time
tests._files.test_animation.TestAnimationWithoutRequest::test_expected_values
Stack Traces | 0.002s run time
self = <tests._files.test_animation.TestAnimationWithoutRequest object at 0x7f9c59576100>
animation = Animation(api_kwargs={'thumb': {'file_id': 'AAMCBAADGQMAATRUmWeRRnqq-8_n1xy8G864s-P-cTq-AAI_GgACawiIUFZOcHUi83csAQAHcw...I_GgACawiIUFZOcHUi83csAQAHcwADNgQ', file_size=2744, file_unique_id='AQADPxoAAmsIiFB4', height=50, width=50), width=640)

    def test_expected_values(self, animation):
>       assert animation.mime_type == self.mime_type
E       AssertionError: assert 'image/gif' == 'video/mp4'
E         
E         - video/mp4
E         + image/gif

tests/_files/test_animation.py:69: AssertionError
tests._files.test_animation.TestAnimationWithRequest::test_send_animation_url_file
Stack Traces | 0.171s run time
self = <tests._files.test_animation.TestAnimationWithRequest object at 0x7f9c5958a0d0>
bot = PytestExtBot[token=696188732:AAGVwEKfHHlNjscxEDNKAwkhGstZ_ko1mC0]
chat_id = '675666224'
animation = Animation(api_kwargs={'thumb': {'file_id': 'AAMCBAADGQMAATRUmWeRRnqq-8_n1xy8G864s-P-cTq-AAI_GgACawiIUFZOcHUi83csAQAHcw...I_GgACawiIUFZOcHUi83csAQAHcwADNgQ', file_size=2744, file_unique_id='AQADPxoAAmsIiFB4', height=50, width=50), width=640)

    async def test_send_animation_url_file(self, bot, chat_id, animation):
        message = await bot.send_animation(
            chat_id=chat_id, animation=self.animation_file_url, caption=self.caption
        )
    
        assert message.caption == self.caption
    
        assert isinstance(message.animation, Animation)
        assert isinstance(message.animation.file_id, str)
        assert isinstance(message.animation.file_unique_id, str)
        assert message.animation.file_id
        assert message.animation.file_unique_id
    
>       assert message.animation.duration == animation.duration
E       AssertionError: assert 1 == 0
E        +  where 1 = Animation(api_kwargs={'thumb': {'file_id': 'AAMCBAADGQMAATOxCGdzRPhVj8AXaIUpWELn9cUbFmGWAAI3AQACqsw9U9IUfTEHfB8TAQAHbQADNgQ', 'file_unique_id': 'AQADNwEAAqrMPVNy', 'file_size': 4451, 'width': 320, 'height': 180}}, duration=1, file_id='CgACAgQAAxkDAAEzsQhnc0T4VY_AF2iFKVhC5_XFGxZhlgACNwEAAqrMPVPSFH0xB3wfEzYE', file_name='game.gif.mp4', file_size=4127, file_unique_id='AgADNwEAAqrMPVM', height=180, mime_type='video/mp4', thumbnail=PhotoSize(file_id='AAMCBAADGQMAATOxCGdzRPhVj8AXaIUpWELn9cUbFmGWAAI3AQACqsw9U9IUfTEHfB8TAQAHbQADNgQ', file_size=4451, file_unique_id='AQADNwEAAqrMPVNy', height=180, width=320), width=320).duration
E        +    where Animation(api_kwargs={'thumb': {'file_id': 'AAMCBAADGQMAATOxCGdzRPhVj8AXaIUpWELn9cUbFmGWAAI3AQACqsw9U9IUfTEHfB8TAQAHbQADNgQ', 'file_unique_id': 'AQADNwEAAqrMPVNy', 'file_size': 4451, 'width': 320, 'height': 180}}, duration=1, file_id='CgACAgQAAxkDAAEzsQhnc0T4VY_AF2iFKVhC5_XFGxZhlgACNwEAAqrMPVPSFH0xB3wfEzYE', file_name='game.gif.mp4', file_size=4127, file_unique_id='AgADNwEAAqrMPVM', height=180, mime_type='video/mp4', thumbnail=PhotoSize(file_id='AAMCBAADGQMAATOxCGdzRPhVj8AXaIUpWELn9cUbFmGWAAI3AQACqsw9U9IUfTEHfB8TAQAHbQADNgQ', file_size=4451, file_unique_id='AQADNwEAAqrMPVNy', height=180, width=320), width=320) = Message(animation=Animation(api_kwargs={'thumb': {'file_id': 'AAMCBAADGQMAATOxCGdzRPhVj8AXaIUpWELn9cUbFmGWAAI3AQACqsw9U9IUfTEHfB8TAQAHbQADNgQ', 'file_unique_id': 'AQADNwEAAqrMPVNy', 'file_size': 4451, 'width': 320, 'height': 180}}, duration=1, file_id='CgACAgQAAxkDAAEzsQhnc0T4VY_AF2iFKVhC5_XFGxZhlgACNwEAAqrMPVPSFH0xB3wfEzYE', file_name='game.gif.mp4', file_size=4127, file_unique_id='AgADNwEAAqrMPVM', height=180, mime_type='video/mp4', thumbnail=PhotoSize(file_id='AAMCBAADGQMAATOxCGdzRPhVj8AXaIUpWELn9cUbFmGWAAI3AQACqsw9U9IUfTEHfB8TAQAHbQADNgQ', file_size=4451, file_unique_id='AQADNwEAAqrMPVNy', height=180, width=320), width=320), caption='Test *animation*', channel_chat_created=False, chat=Chat(first_name='PTB', id=675666224, last_name='Test user', type=<ChatType.PRIVATE>), date=datetime.datetime(2025, 1, 22, 19, 27, 3, tzinfo=datetime.timezone.utc), delete_chat_photo=False, document=Document(api_kwargs={'thumb': {'file_id': 'AAMCBAADGQMAATOxCGdzRPhVj8AXaIUpWELn9cUbFmGWAAI3AQACqsw9U9IUfTEHfB8TAQAHbQADNgQ', 'file_unique_id': 'AQADNwEAAqrMPVNy', 'file_size': 4451, 'width': 320, 'height': 180}}, file_id='CgACAgQAAxkDAAEzsQhnc0T4VY_AF2iFKVhC5_XFGxZhlgACNwEAAqrMPVPSFH0xB3wfEzYE', file_name='game.gif.mp4', file_size=4127, file_unique_id='AgADNwEAAqrMPVM', mime_type='video/mp4', thumbnail=PhotoSize(file_id='AAMCBAADGQMAATOxCGdzRPhVj8AXaIUpWELn9cUbFmGWAAI3AQACqsw9U9IUfTEHfB8TAQAHbQADNgQ', file_size=4451, file_unique_id='AQADNwEAAqrMPVNy', height=180, width=320)), from_user=User(first_name='PTB tests on Travis using CPython 2.7', id=696188732, is_bot=True, username='ptb_travis_cpython_27_bot'), group_chat_created=False, message_id=3429541, supergroup_chat_created=False).animation
E        +  and   0 = Animation(api_kwargs={'thumb': {'file_id': 'AAMCBAADGQMAATRUmWeRRnqq-8_n1xy8G864s-P-cTq-AAI_GgACawiIUFZOcHUi83csAQAHcwADNgQ', 'file_unique_id': 'AQADPxoAAmsIiFB4', 'file_size': 2744, 'width': 50, 'height': 50}}, duration=0, file_id='CgACAgQAAxkDAAE0VJlnkUZ6qvvP59ccvBvOuLPj_nE6vgACPxoAAmsIiFBWTnB1IvN3LDYE', file_name='game.gif', file_size=36535, file_unique_id='AgADPxoAAmsIiFA', height=360, mime_type='image/gif', thumbnail=PhotoSize(file_id='AAMCBAADGQMAATRUmWeRRnqq-8_n1xy8G864s-P-cTq-AAI_GgACawiIUFZOcHUi83csAQAHcwADNgQ', file_size=2744, file_unique_id='AQADPxoAAmsIiFB4', height=50, width=50), width=640).duration

tests/_files/test_animation.py:271: AssertionError
tests._files.test_animation.TestAnimationWithRequest::test_send_all_args
Stack Traces | 0.692s run time
self = <tests._files.test_animation.TestAnimationWithRequest object at 0x7f9c59581b80>
bot = PytestExtBot[token=696188732:AAGVwEKfHHlNjscxEDNKAwkhGstZ_ko1mC0]
chat_id = '675666224'
animation_file = <_io.BufferedReader name='.../tests/data/game.gif'>
animation = Animation(api_kwargs={'thumb': {'file_id': 'AAMCBAADGQMAATRUmWeRRnqq-8_n1xy8G864s-P-cTq-AAI_GgACawiIUFZOcHUi83csAQAHcw...I_GgACawiIUFZOcHUi83csAQAHcwADNgQ', file_size=2744, file_unique_id='AQADPxoAAmsIiFB4', height=50, width=50), width=640)
thumb_file = <_io.BufferedReader name='.../tests/data/thumb.jpg'>

    async def test_send_all_args(self, bot, chat_id, animation_file, animation, thumb_file):
        message = await bot.send_animation(
            chat_id,
            animation_file,
            duration=self.duration,
            width=self.width,
            height=self.height,
            caption=self.caption,
            parse_mode="Markdown",
            disable_notification=False,
            protect_content=True,
            thumbnail=thumb_file,
            has_spoiler=True,
            show_caption_above_media=True,
        )
    
        assert isinstance(message.animation, Animation)
        assert isinstance(message.animation.file_id, str)
        assert isinstance(message.animation.file_unique_id, str)
        assert message.animation.file_id
        assert message.animation.file_unique_id
>       assert message.animation.file_name == animation.file_name
E       AssertionError: assert 'game.gif.mp4' == 'game.gif'
E         
E         - game.gif
E         + game.gif.mp4
E         ?         ++++

tests/_files/test_animation.py:237: AssertionError

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

@Bibo-Joshi
Copy link
Member Author

I can' reproduce the failure locally :/ I'll try to add some debug prints

@Bibo-Joshi Bibo-Joshi marked this pull request as draft December 31, 2024 14:42
@Bibo-Joshi Bibo-Joshi marked this pull request as ready for review December 31, 2024 16:21
@Bibo-Joshi
Copy link
Member Author

Yeah, that worked 🎊

Copy link
Member

@harshil21 harshil21 left a comment

Choose a reason for hiding this comment

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

Well written test and logic overall!

telegram/ext/_aioratelimiter.py Outdated Show resolved Hide resolved
telegram/ext/_aioratelimiter.py Show resolved Hide resolved
tests/ext/test_ratelimiter.py Outdated Show resolved Hide resolved
tests/ext/test_ratelimiter.py Outdated Show resolved Hide resolved
tests/ext/test_ratelimiter.py Outdated Show resolved Hide resolved
Copy link
Member

@harshil21 harshil21 left a comment

Choose a reason for hiding this comment

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

LGTM!

@Bibo-Joshi Bibo-Joshi merged commit 61b87ba into master Jan 23, 2025
25 checks passed
@Bibo-Joshi Bibo-Joshi deleted the feature/apd-ratelimiter branch January 23, 2025 04:59
@github-actions github-actions bot locked and limited conversation to collaborators Jan 31, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

🔌 enhancement pr description: enhancement ℹ️ needs-wiki-update information: needs-wiki-update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support allow_paid_broadcast in AIORateLimiter

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.