[Birthday] Add test coverage#661
Open
quachtridat wants to merge 5 commits into
Open
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`.
Member
Author
This is an extensively large commit that adds, readjusts and consolidates tests covering most functions and methods in `commandsCore.py`, `converters.py`, and `core.py`. Minor adjustments are made to: - `commandsCore.py` so that only `datetime.date` needs to be imported. - `converters.py` to rely on `datetime.date` only. The new file `conftest.py` contains multiple Pytest fixtures to be used by a large number of tests. Some fixtures here are made to patch specific attributes of Red and the Birthday cog to simulate the cog as close to production as possible. Locale setup is also done as an "auto-use" fixture in this file, which reduces the locale boilerplate code in other test files, as this cog interacts with date objects actively. `testBirthday.py` is deleted in this commit. It is superseded by `testCore.py`. Some adjustments are done to `testConverters.py` to make the test compact. Note that there is an extensive use of the type hint pattern `typing.Union[mock.Mock, Type]`. This is done so that Python language servers can apply syntax highlighting instructions based on the `Type`, while the objects in test stay as `mock.Mock` instances.
a13e48e to
2f615df
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is an extensively large PR that adds, readjusts and consolidates tests covering most functions and methods in
commandsCore.py,converters.py, andcore.py.Notes
Minor adjustments are made to:
commandsCore.pyso that onlydatetime.dateneeds to be imported.converters.pyto rely ondatetime.dateonly.The new file
conftest.pycontains multiple Pytest fixtures to be used by a large number of tests. Some fixtures here are made to patch specific attributes of Red and the Birthday cog to simulate the cog as close to production as possible. Locale setup is also done as an auto-use" fixture in this file, which reduces the locale boilerplate code in other test files, as this cog interacts with date objects actively.testBirthday.pyis deleted in this commit. It is superseded bytestCore.py.Some adjustments are done to
testConverters.pyto make the test compact.Note that there is an extensive use of the type hint pattern
typing.Union[mock.Mock, Type]. This is done so that Python language servers can apply syntax highlighting instructions based on theType, while the objects in test stay asmock.Mockinstances.