-
Notifications
You must be signed in to change notification settings - Fork 7
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
Helper function to get flask.request.patron #2178
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2178 +/- ##
==========================================
+ Coverage 91.00% 91.01% +0.01%
==========================================
Files 359 360 +1
Lines 41136 41183 +47
Branches 8842 8845 +3
==========================================
+ Hits 37436 37483 +47
Misses 2424 2424
Partials 1276 1276 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
): | ||
return PatronAuthTokenControllerFixture(db, services_fixture) | ||
def patron_auth_token_fixture(db: DatabaseTransactionFixture): | ||
return PatronAuthTokenControllerFixture(db) | ||
|
||
|
||
class TestPatronAuthTokenController: |
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.
All the test changes here are to update these tests to use FlaskAppFixture
, so we can set the patron by passing it to flask_app_fixture.test_request_context
. The tests should be functionally the same.
def playtime_entries_controller_fixture( | ||
db: DatabaseTransactionFixture, | ||
) -> PlaytimeEntriesControllerFixture: | ||
return PlaytimeEntriesControllerFixture(db) | ||
|
||
|
||
class TestPlaytimeEntriesController: |
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.
All the changes to these tests are so we can use flask_app_fixture
in the tests, which allows us to pass patron
and library
to test_request_context
. That way we aren't directly manipulating flask.request
in the tests.
@@ -18,37 +19,43 @@ def controller(db: DatabaseTransactionFixture) -> DeviceTokensController: | |||
return DeviceTokensController(mock_manager) | |||
|
|||
|
|||
@patch("palace.manager.api.controller.device_tokens.flask") |
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.
The device tokens tests took an unusual approach, and instead of using the test_request_context
decorator, it patched the flask
object. This stopped working with these updates, since we are not loading the patron directly from flask.request
anymore.
These changes just update these tests to be more in line with our other tests using the flask_app_fixture
to setup the request context. There should be no functional changes to the tests.
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 good! 🛠️
9e872ed
to
45d32c3
Compare
Description
Similar to #2177 but for
flask.request.patron
.Add a helper function get_request_patron() to get
flask.request.patron
in a type safe way. Update the existing code to use the new helper.Motivation and Context
Consistency in how we are accessing attributes set on
flask.request
.How Has This Been Tested?
Checklist