Skip to content

Upgrade to django-privates 4.0+#6296

Merged
sergei-maertens merged 10 commits into
mainfrom
chore/upgrade-django-privates
May 22, 2026
Merged

Upgrade to django-privates 4.0+#6296
sergei-maertens merged 10 commits into
mainfrom
chore/upgrade-django-privates

Conversation

@sergei-maertens
Copy link
Copy Markdown
Member

@sergei-maertens sergei-maertens commented May 15, 2026

Periodic maintenance stuff and all that :)

Turns out this hits quite a bit of dependencies and test code. Rough overview of the changes:

  • added the missing @temp_private_root decorators and/or updated them to not clear the files created in the test case data setup
  • made (test) code agnostic about the storage implementation details - not everything is always backend by a local filesystem!
  • updated related dependencies: zgw-consumers, django-simple-certmanager and django-digid-eherkenning that all make use of django-privates too
  • ran makemigrations
  • added CI step to fail the build if the effect of missing @temp_private_root decorators is detected (local private_media files are created)
  • Updated a factory method to not create the submission PDF by default

@sergei-maertens sergei-maertens marked this pull request as draft May 15, 2026 15:16
@sergei-maertens sergei-maertens force-pushed the chore/upgrade-django-privates branch 6 times, most recently from 1383a66 to 222a21d Compare May 16, 2026 15:19
@codecov
Copy link
Copy Markdown

codecov Bot commented May 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.10%. Comparing base (acad98d) to head (74e6c69).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6296   +/-   ##
=======================================
  Coverage   97.10%   97.10%           
=======================================
  Files         868      869    +1     
  Lines       33117    33147   +30     
  Branches     3045     3048    +3     
=======================================
+ Hits        32159    32189   +30     
  Misses        646      646           
  Partials      312      312           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sergei-maertens sergei-maertens force-pushed the chore/upgrade-django-privates branch from 407f371 to ac65b9a Compare May 22, 2026 13:53
@sergei-maertens sergei-maertens marked this pull request as ready for review May 22, 2026 13:54
@sergei-maertens sergei-maertens force-pushed the chore/upgrade-django-privates branch from ac65b9a to cc5279f Compare May 22, 2026 14:43
* Removed reference to removed setting
* Updated how/which UUIDs are stored in the session
* Updated formatting to fit within 80 cols
Now that in tests an in-memory storage is used, but the subprocess call
expects the input file to exist on disk, we have to use the file field
and it's storage as abstraction rather than an on-disk filesystem path.

In tests we can now copy the file to a temp file, while in prod with
regular storages the plain path is emitted.
@sergei-maertens sergei-maertens force-pushed the chore/upgrade-django-privates branch from cc5279f to e322cda Compare May 22, 2026 15:35
It now uses the STORAGES setting and its own settings have been removed.

Tests should not assume anything about the file system either and
instead make assertions based on the storage used.
These should avoid hitting the filesystem for real when running tests,
clobbering the private-media directory on local dev environments.

You can track down the violating tests by changing the file permissions
so that the directory is only writable to root:

  chown root private_media
  chmod go-rx private_media

Some tests are failing that are logical in this case - so judge them
accordingly.
@sergei-maertens sergei-maertens force-pushed the chore/upgrade-django-privates branch from e322cda to 74e6c69 Compare May 22, 2026 21:49
@sergei-maertens sergei-maertens merged commit 66689e4 into main May 22, 2026
17 of 18 checks passed
@sergei-maertens sergei-maertens deleted the chore/upgrade-django-privates branch May 22, 2026 21:50
@sergei-maertens
Copy link
Copy Markdown
Member Author

Merged like this - the changes were discussed with the team on Monday and no further input/checks were deemed necessary :)

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.

1 participant