-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Summary
Historically I've used code like this:
SERVER = getattr(settings, "PRINCE_SERVER", None)
BINARY = getattr(settings, "PRINCE_BINARY", "/usr/local/bin/prince")This allows for a default value in the library without requiring the project owner to add any configuration to their projects settings.py file.
This project is open source, but I'm unaware of anyone else making use of it, so I'm happy to impose some extra pain on myself at the expense/benefit of relying on django-constance for controlling these values.
Identify all the "optional settings" across all of vitriolic
Find all the places where our code looks up values from django.conf.settings which aren't official Django project settings.
Once identified, convert them all to django-constance values instead. In doing this, we will need to add system checks to validate that:
'constance'is in theINSTALLED_APPSlistCONSTANCE_CONFIGis defined indjango.conf.settings- each custom configuration item is defined correctly in
CONSTANCE_CONFIG
The test project will also need to be updated with this configuration.
Make sure all dynamic values are tested
Check for our existing coverage on these configurable values - it is likely we presently do not have sufficient coverage and should add more testing around them.
Make use of the django-constance provided overide_config decorator to adjust the values in test suite.
It is acceptable to check for exceptions when changing values dynamically; for example the PRINCE_BINARY example - changing that to a non-existent path would expect to throw an OSError for NOTFOUND - that still proves the dynamic value was respected, even if it won't work.
Final thoughts
This is going to be very invasive! Keep code changes minor to make the review easier. It should be clear to a human reviewer that we're doing a swap from home-rolled to reusable settings without changing any of the other behaviours.
If you uncover a bug while going through this (ie. a test you write or modify fails) mark that test case to skip and put a clear "FIXME" note in the skip reason so that we can track back to it.