Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0dc37df

Browse files
♻️ update settings key
1 parent 2ac9783 commit 0dc37df

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

‎gitlab_webhooks/settings.py‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
from django.conf import ImproperlyConfigured
22
from django.conf import settings as django_settings
33

4+
from .constants import Events
5+
6+
SETTINGS_KEY = "DJANGO_GITLAB_WEBHOOKS"
7+
48

59
def load_settings() -> None:
610
try:
7-
settings = django_settings.GITLAB_WEBHOOKS
11+
settings = getattr(django_settings, SETTINGS_KEY)
812
except AttributeError:
9-
raise ImproperlyConfigured("GITLAB_WEBHOOKS settings is missing!")
13+
raise ImproperlyConfigured(
14+
"{settings_key} settings is missing!".format(settings_key=SETTINGS_KEY)
15+
)
1016

1117
if not isinstance(settings, dict):
12-
raise ImproperlyConfigured("GITLAB_WEBHOOKS is not a dict!")
18+
raise ImproperlyConfigured(
19+
"{settings_key} is not a dict!".format(settings_key=SETTINGS_KEY)
20+
)
1321

14-
# Your settings goes here ...
15-
# if "ALLOWED_EVENTS" not in settings:
16-
# settings["ALLOWED_EVENTS"] = ["test"]
22+
if not settings.get("ALLOWED_EVENTS"):
23+
settings["ALLOWED_EVENTS"] = Events.values()

‎tests/test_settings.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ def test_load_settings_success():
88

99

1010
def test_missed_settings(settings):
11-
del settings.GITLAB_WEBHOOKS
11+
del settings.DJANGO_GITLAB_WEBHOOKS
1212
with pytest.raises(ImproperlyConfigured):
1313
app_settings.load_settings()
1414

1515

1616
def test_settings_is_not_a_dict(settings):
17-
settings.GITLAB_WEBHOOKS = list()
17+
settings.DJANGO_GITLAB_WEBHOOKS = list()
1818
with pytest.raises(ImproperlyConfigured):
1919
app_settings.load_settings()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /