fix(graphql): lowercase status/role enum + OTP test mock - #6
Merged
Conversation
CI failures were two independent issues:
1. graphene-django 3.2.3 auto-converts CharField `choices` to a GraphQL Enum
whose values serialize UPPERCASE ("PENDING", "STATION_OWNER"). This broke
the booking status assertions (3 failures) and silently breaks the mobile
client, which parses the lowercase raw values for both Booking.status and
User.role. Set `convert_choices_to_enum = False` on BookingType and UserType
to return the raw lowercase values. No test asserts the uppercase form and
status/role are only ever passed as quoted string inputs, so inputs are
unaffected.
2. OtpModelTests mocked `accounts.models.secrets.choice`, but `secrets` is a
shared module, so the patch also intercepted Django make_password()'s salt
generation and starved the 6-value side_effect -> RuntimeError (StopIteration
under PEP 479 / Python 3.12). The mock now only fixes the OTP digit alphabet
and delegates any other alphabet (the salt) to the real RNG.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The workflow sets `defaults.run.working-directory: ev_backend` for every run
step, so `docker build ... ev_backend` resolved the context to
ev_backend/ev_backend (the inner settings package, which has no Dockerfile):
failed to read dockerfile: open Dockerfile: no such file or directory
The tracked Dockerfile lives at ev_backend/Dockerfile, so with the step already
running inside ev_backend the context must be `.`. Verified the Dockerfile and
.dockerignore are coherent for a context of `.` (requirements.txt, entrypoint.sh,
manage.py and the app packages are all present and un-ignored).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Fixes the CI
manage.py testrun (3 failures + 1 error). Two unrelated issues.1. Booking status / user role serialized UPPERCASE (3 failures)
graphene-django 3.2.3 auto-converts a
CharField(choices=…)into a GraphQL Enum, whose values serialize as the UPPERCASE name — sostatusreturned"PENDING"/"APPROVED"/"CANCELLED"instead of the lowercase DB value the tests assert:Set
convert_choices_to_enum = Falseon BookingType and UserType to return the raw lowercase values. This restores the lowercase contract that both the test suite and the mobile client depend on (the Flutter client parses lowercasestatusandrole—User.rolehad the same latent bug, fixed here proactively).Verified safe: no test asserts the uppercase form, and
status/roleare only ever passed as quoted string arguments (never enum literals), so query inputs are unaffected.2. OTP test starved Django's salt RNG (1 error)
OtpModelTestspatchedaccounts.models.secrets.choicewith a 6-valueside_effect. Becausesecretsis a shared module, the patch also interceptedmake_password()'s salt generation, which drained the iterator →RuntimeError: generator raised StopIteration(PEP 479 / Python 3.12).The mock now only fixes the OTP digit alphabet and delegates any other alphabet (the salt) to the real RNG.
Verification
Backend Python can't run in my local env, so changes are syntax-verified (
py_compile) and reasoned against the suite (grep confirms no uppercase/enum-input dependencies). Please let CI run the suite to confirm green.🤖 Generated with Claude Code