Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Settings module + Browsable API and debug settings #84

Merged
merged 1 commit into from
Dec 14, 2021

Conversation

stevelacey
Copy link
Contributor

@stevelacey stevelacey commented Dec 14, 2021

Wraps settings up into their own module for visibility, and adds an option to disable browsable api and debug mode.

Also switches testing to exercise debug mode, which seemingly wasn't happening (+0.5% coverage) and fixes a bug where EmptyResultSet would throw when trying to render the sql for the debug output.

What Worf gif best describes this PR or how it makes you feel?

Checklist

  • This PR increases test coverage
  • This PR includes README updates reflecting any new features/improvements to the framework

@stevelacey stevelacey force-pushed the improvement/settings-module branch 2 times, most recently from c3fe7ab to 85ff7ba Compare December 14, 2021 11:01
@stevelacey stevelacey changed the title Settings module + Browsable API toggle Settings module + WORF_BROWSABLE_API and WORF_DEBUG settings Dec 14, 2021
@stevelacey stevelacey changed the title Settings module + WORF_BROWSABLE_API and WORF_DEBUG settings Settings module + Browsable API and debug settings Dec 14, 2021
@@ -8,44 +8,32 @@ def pytest_configure():
from django.conf import settings

settings.configure(
SECRET_KEY="secret",
DEBUG=True,
Copy link
Contributor Author

@stevelacey stevelacey Dec 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fun. This was never actually True. Seems configure cannot override the default from global_settings.

@stevelacey stevelacey force-pushed the improvement/settings-module branch 2 times, most recently from 399d1ca to 3f1a175 Compare December 14, 2021 11:48
@stevelacey stevelacey force-pushed the improvement/settings-module branch from 3f1a175 to 543e994 Compare December 14, 2021 11:50
Comment on lines -13 to +33
INSTALLED_APPS=[
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"tests",
"worf",
],
MIDDLEWARE=[
"django.middleware.common.CommonMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
],
ROOT_URLCONF="tests.urls",
DATABASES={
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": "db.sqlite3",
}
},
INSTALLED_APPS=[
"django.contrib.auth",
"django.contrib.contenttypes",
"tests",
"worf",
],
PASSWORD_HASHERS=["django.contrib.auth.hashers.MD5PasswordHasher"],
ROOT_URLCONF="tests.urls",
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"APP_DIRS": True,
},
],
TIME_ZONE="UTC",
USE_I18N=True,
USE_L10N=True,
USE_I18N=False,
USE_L10N=False,
Copy link
Contributor Author

@stevelacey stevelacey Dec 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stripped some of this down given it doesn't matter and/or saves on cpu.

Comment on lines +184 to +188
if settings.WORF_DEBUG:
try:
self.query = str(queryset.query)
except EmptyResultSet:
self.query = None
Copy link
Contributor Author

@stevelacey stevelacey Dec 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might have seen this exception when using filters that create an impossible query. Outside of debug mode lists will yield [] but when debug mode is on they'd fail here trying to output the sql for the debug.

The reason I've addressed this here is because now that debug mode is actually on during testing, one test was failing here given it exercises an impossible query.

@wadewilliams wadewilliams merged commit 1638bd0 into master Dec 14, 2021
@wadewilliams wadewilliams deleted the improvement/settings-module branch December 14, 2021 19:52
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