Remove apparently unneeded INSTALLED_APPS setting, as well as the LTI_CUSTOM_ROLE_KEY setting.  Update middleware to use hasattr instead of getattr.  Update tests to set the LTI_CUSTOM_ROLE_KEY django setting with a context manager block in each required test.