Skip to content

Conversation

@Andrej730
Copy link
Contributor

Added new property to Job class - next_t, it will show the datetime when the job will be executed next time.The property is updated during JobQueue._put method, right after job is added to queue.

Related to #1676

Added new property to Job class - next_t, it will show the datetime when the job will be executed next time.
The property is updated during JobQueue._put method, right after job is added to queue.
Related to python-telegram-bot#1676
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 PR! Please see my comments below.
Also, we'll need test cases for the new property. Please have a look at test_jobqueue.py and add test cases that make sure that both the setter and getter for next_t work correctly (especially between calls of repeating jobs).
Test Official is failing because we haven't yet implemented Bot API 4.5 - you can ignore that.

@Bibo-Joshi Bibo-Joshi added this to the 12.5 milestone Jan 1, 2020
@Bibo-Joshi Bibo-Joshi added enhancement 📋 pending-reply work status: pending-reply labels Jan 1, 2020
1. Added setter for next_t - now JobQueue doesn't access protected Job._next_t.
2. Fixed Job class docstring.
3. Added test for next_t property.
4. Set next_t to None for run_once jobs that already ran.
1. next_t setter now can accept datetime type.
2. added test for setting datetime to next_t and added some asserts that check tests results.
3. Also noticed Job.days setter raises ValueError when it's more appropriate to raise TypeError.
@Andrej730 Andrej730 requested a review from Bibo-Joshi January 3, 2020 08:11
1. Changed type of error raised by interval setter from ValueError to TypeError..
2. Fixed test_warning after changing type of errors in Job.days and Job.interval.
3. Added Number type to next_t setter - now it can accept int too.
@Andrej730 Andrej730 force-pushed the next_t_branch branch 2 times, most recently from e423447 to f05fe3f Compare January 3, 2020 09:06
Added _UTC and _UtcOffsetTimezone for python 2 compatibility
@Andrej730 Andrej730 force-pushed the next_t_branch branch 2 times, most recently from 2dfcd29 to 56fe5f7 Compare January 3, 2020 11:48
1. Replaced "datetime.replace tzinfo" with "datetime.astimezone"
2. Moved testing next_t setter to separate test.
3. Changed test_job_next_t_setter so it now uses non UTC timezone.
1. Added option to define Job.tzinfo from run_once (by when.tzinfo) and run_repeating (first.tzinfo)
2. Added test to check that tzinfo is always passed correctly.
@Andrej730
Copy link
Contributor Author

Because after this PR Job.timetz will be used more often, I've added option to define Job.timetz from run_repeating and run_once by passing timetz in one of their datetime arguments (discussed in #1696).

@Andrej730 Andrej730 requested a review from Bibo-Joshi February 22, 2020 09:11
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.

Must be merged after #1696, because the changes from there are in here already.

If #1705 is morged before this, the tzinfo changes will be needed for run_monthly, too.

CI: test_set_game_score. Unrelated

Copy link
Member

@tsnoam tsnoam 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, looks very good. We definitely should have it.
However, some small changes a required to make it air-tight.

@Bibo-Joshi
Copy link
Member

Codacy fails as expected, test fail is unrelated. Merging.

Thank you for your contribution, @Andrej730!

@Bibo-Joshi Bibo-Joshi merged commit 110e2df into python-telegram-bot:master Apr 18, 2020
Bibo-Joshi added a commit to daviddl9/python-telegram-bot that referenced this pull request May 1, 2020
Bibo-Joshi added a commit that referenced this pull request May 2, 2020
* added monthly job

* removed fold argument

* addressed pr comments

* addressed pr comments

* made changes from pr review

* updated comments

* clean up code

* Update .pre-commit-config.yaml

* Minor cleanup

* Update according to #1685, minor robustness changes

Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 18, 2020
@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.

3 participants