-
Notifications
You must be signed in to change notification settings - Fork 17
Async/Sync Tests Rewrite #39
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
base: master
Are you sure you want to change the base?
Conversation
Start working on ClientHybrid class. Denotes a type of client that calls both the sync and async versions of a client's fetch_x methods. This is so that, when testing, you don't need two tests for each client type. The guarantee is that the return types between the two clients are the same, so the subsequent tests must also be valid for both of them. This is backed up by a `HybridMethodProxy` class which basically acts as the actual caller returned by the ClientHyrbid to do some validation.
…_fetch_shop to use correct test functions
…tions for known types.
…alidation functions. Kept them as `_` to denote how they are not exported.
…his for every API call.
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.
Looks pretty good to me. Addionally we might want to link the Tests README within the normal README. Also the Changelog note needs to be added, since it got lost during re-creating the PR.
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.
I think it would be nice to directly embed links to those files within the readme for easy access.
|
||
##### Test Client Hybrid: `test_client_hybrid.py` | ||
|
||
The tests define a custom `ClientHybrid` class (in `./client/test_client_hybrid.py`). This class wraps a `Client` to act as an intermediatory between a requested API call and the actual method. When an API call is requested, the `ClientHybrid` will call **both** the async `Client` version and the `SyncClient` version of the method. The results are then compared to ensure that they are the same. |
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.
Any reason for ./
within the brackets?
Co-authored-by: Lucas Hardt <[email protected]>
Async/Sync Tests Rewrite
Currently, the tests for both the async and sync clients have separate files, and thus, have a lot of repeated code.
I aim to merge this into one, ensuring that both clients are functioning as expected and strengthening the safety of all available tests.
Overall Idea
I'm planning to create some sort of mock Client/SyncClient hybrid that calls methods from both clients at once when requested. Pytest tests do not run in parallel, so although this is not the best solution it will ensure the following:
This will effectively merge the two independent test files into one, allowing for easier maintainability and readability.
This PR stems from the ongoing #29 PR to migrate all new features to this new test system.
Misc Changes
abc.ReconstructAble
to fix changes withfrom_dict
classmethod typing annotations.attribute_table.py
,examples/discord_integration.py
,abc.py
,aes.py
,asset.py
,banner.py
,client.py
,cosmetics/*.py
,cosmetics/variants/*.py
,errors.py
,http.py
,images.py
,map.py
,new.py
,new_display_asset.py
,news.py
,playlist.py
,proxies.py
,shop.py
, andstats.py
.synchronize
workflow trigger in thepull_request
category. This caused tests to run twice in an active PR. Now, tests run when pushed to a branch, when a PR is opened, or when a PR is reopened.