Skip to content

fix(graphql): lowercase status/role enum + OTP test mock - #6

Merged
tedtadesse merged 2 commits into
developfrom
bugfix/graphql-choice-enum-and-otp-mock
Jul 14, 2026
Merged

fix(graphql): lowercase status/role enum + OTP test mock#6
tedtadesse merged 2 commits into
developfrom
bugfix/graphql-choice-enum-and-otp-mock

Conversation

@tedtadesse

Copy link
Copy Markdown
Collaborator

Fixes the CI manage.py test run (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 — so status returned "PENDING"/"APPROVED"/"CANCELLED" instead of the lowercase DB value the tests assert:

AssertionError: 'PENDING' != 'pending'   (createBooking.booking.status)
AssertionError: 'APPROVED' != 'approved' (updateBookingStatus)
AssertionError: 'CANCELLED' != 'cancelled' (cancelBooking)

Set convert_choices_to_enum = False on 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 lowercase status and roleUser.role had the same latent bug, fixed here proactively).

Verified safe: no test asserts the uppercase form, and status/role are 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)

OtpModelTests patched accounts.models.secrets.choice with a 6-value side_effect. Because secrets is a shared module, the patch also intercepted make_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

tewodros-tadesse and others added 2 commits July 14, 2026 11:27
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>
@tedtadesse
tedtadesse merged commit 888b358 into develop Jul 14, 2026
2 checks passed
@tedtadesse
tedtadesse deleted the bugfix/graphql-choice-enum-and-otp-mock branch July 14, 2026 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants