Skip to content

Commit e81ca43

Browse files
Use app settings SLUG as default mention pattern
1 parent 15d2c1c commit e81ca43

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

src/django_github_app/mentions.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
from django.utils import timezone
1111
from gidgethub import sansio
1212

13+
from .conf import app_settings
14+
1315

1416
class EventAction(NamedTuple):
1517
event: str
@@ -166,9 +168,9 @@ def extract_mentions_from_event(
166168
if not comment:
167169
return []
168170

169-
# If no pattern specified, use bot username (TODO: get from settings)
171+
# If no pattern specified, use bot username from settings
170172
if username_pattern is None:
171-
username_pattern = "bot" # Placeholder
173+
username_pattern = app_settings.SLUG
172174

173175
mentions: list[ParsedMention] = []
174176
potential_mentions = extract_all_mentions(comment)

tests/test_mentions.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@
99

1010
from django_github_app.mentions import Comment
1111
from django_github_app.mentions import MentionScope
12-
from django_github_app.mentions import get_match
1312
from django_github_app.mentions import extract_mentions_from_event
13+
from django_github_app.mentions import get_match
14+
15+
16+
@pytest.fixture(autouse=True)
17+
def setup_test_app_name(override_app_settings):
18+
with override_app_settings(NAME="bot"):
19+
yield
1420

1521

1622
@pytest.fixture

tests/test_routing.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
from django_github_app.views import BaseWebhookView
1515

1616

17+
@pytest.fixture(autouse=True)
18+
def setup_test_app_name(override_app_settings):
19+
with override_app_settings(NAME="bot"):
20+
yield
21+
22+
1723
@pytest.fixture(autouse=True)
1824
def test_router():
1925
import django_github_app.views

0 commit comments

Comments
 (0)