Closed lalver1 closed 1 month ago
Click to see where and how coverage changed
File Statements Missing Coverage Coverage
(new stmts)Lines missing
benefits/oauth
analytics.py
68
views.py
Project Total
This report was generated by python-coverage-comment-action
I'm unsure what to do about missing tests for lines 68-71 in
We addressed this during our dev workshop 👍 benefits.oauth.analytics.finished_sign_in
since finished_sign_in
doesn't return a value; I likely need a mocker.
Closes #2049
How to test
To test the error condition, insert something like
claim_value = "20"
after line 73 inbenefits.oauth.views.authorize
. Then check that"error_code": 20
appears as a property of"event_properties"
in the log.Notes
The behavior originally described in these notes was fixed by #2127.
When running the testtest_authorize_success_without_verifier_claim
, the oauth middlewareVerifierUsesAuthVerificationSessionRequired
that decorates theauthorize
view seems to behave differently compared to debugging the application.Specifically, line 19 inbenefits/oauth/middleware.py
evaluates to a<Mock>
object if running the test, but it evaluates to a boolean if debugging the application.~~To see this behavior, debug the test and notice that line 19 evaluates to a
<Mock>
object, so theif
condition evaluates toTrue
and returnsNone
instead of returning the user error page. However, when debugging the application and settingclaim
inAuthProvider
to blank (to simulate a missing verifier claim in the database), line 19 will evaluate toFalse
and the conditional will return the user error page.~~Also, seems likeverifier.auth_provider.claim = ""
in the test only setsverifier_claim = verifier.auth_provider.claim
(line 64 in the view). For a test closer to the behavior being tested, we may need to set theclaim
to blank in a fixture similar tomodel_AuthProvider_with_verification
.