-
Notifications
You must be signed in to change notification settings - Fork 21
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
[Birthday] Cog model restructure #660
base: V3/testing
Are you sure you want to change the base?
[Birthday] Cog model restructure #660
Conversation
Restructure cog `Birthday` according to SFUAnime#608. No functional changes expected. Command handlers that utilize the `MonthDayConverter` now perform a "typing cast" to inform static type checkers that the birthday being passed to the command handlers as `MonthDayConverter` will be subsequently passed to the corresponding methods in `CommandsCore` as type `datetime.datetime` instead of `MonthDayConverter`. Note that Python typing cast does not change or restrict any functionalities because it is only information to static type checkers. `MonthDayConverter` now exposes the `InputType` and `OutputType` as type aliases so that code utilizes the converted can be type-hinted better. The birth year constant 2020 is moved to `constants.py` as `DEFAULT_YEAR`.
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.
Sorry this was long overdue, did a first pass.
# Cancel the background task on cog unload. | ||
def __unload(self): # pylint: disable=invalid-name | ||
self.bgTask.cancel() | ||
|
||
def cog_unload(self): | ||
self.__unload() |
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.
Can we remove the __unload
method and just leave cog_unload
? I think this was ported from cog v2 days where it was looking for __unload()
, so I don't think it's needed any more.
# Cancel the background task on cog unload. | |
def __unload(self): # pylint: disable=invalid-name | |
self.bgTask.cancel() | |
def cog_unload(self): | |
self.__unload() | |
def cog_unload(self): | |
self.bgTask.cancel() |
Summary
Restructure cog
Birthday
according to #608. No functional changes expected.Notes
Command handlers that utilize the
MonthDayConverter
now perform a "typing cast" to inform static type checkers that the birthday being passed to the command handlers asMonthDayConverter
will be subsequently passed to the corresponding methods inCommandsCore
as typedatetime.datetime
instead ofMonthDayConverter
. Note that Python typing cast does not change or restrict any functionalities because it is only information to static type checkers.MonthDayConverter
now exposes theInputType
andOutputType
as type aliases so that code utilizes the converted can be type-hinted better.The birth year constant 2020 is moved to
constants.py
asDEFAULT_YEAR
.Tests
The testing for this PR is done a bit specially.
Automated testing will be done by #661, and manual testing will be gradually done within this PR's thread.
Help
Add birthday
After setting the role:
After the date display timeout:
Re-adding:
Channel
Delete
After setting the role:
List
After adding a birthday:
Role
Self
After enabling the self-birthday functionality:
(the above happens in DM)
Self birthday toggle
Test
Unassign
After setting the role:
Daily add
This tests the
_dailyAdd
function inCore
. The local machine's time is manually adjusted to test this.Daily sweep
This tests the
_dailySweep
function inCore
. The local machine's time is manually adjusted to test this.(the role is no longer there)