Skip to content

Commit 41a0f68

Browse files
rename internal webhook event modules (#32)
* rename internal webhook event modules * rename functions * delete old modules
1 parent a7d7b68 commit 41a0f68

File tree

7 files changed

+34
-34
lines changed

7 files changed

+34
-34
lines changed

src/django_github_app/apps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ class GitHubAppConfig(AppConfig):
1212

1313
@override
1414
def ready(self):
15-
from . import events # noqa: F401
15+
from .events import ahandlers # noqa: F401
Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +0,0 @@
1-
from __future__ import annotations
2-
3-
from . import installation
4-
from . import repository
5-
6-
__all__ = [
7-
"installation",
8-
"repository",
9-
]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from __future__ import annotations
2+
3+
from . import ainstallation
4+
from . import arepository
5+
6+
__all__ = [
7+
"ainstallation",
8+
"arepository",
9+
]

src/django_github_app/events/installation.py renamed to src/django_github_app/events/ainstallation.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212

1313

1414
@gh.event("installation", action="created")
15-
async def create_installation(event: sansio.Event, gh: GitHubAPI, *args, **kwargs):
15+
async def acreate_installation(event: sansio.Event, gh: GitHubAPI, *args, **kwargs):
1616
await Installation.objects.acreate_from_event(event)
1717

1818

1919
@gh.event("installation", action="deleted")
20-
async def delete_installation(event: sansio.Event, gh: GitHubAPI, *args, **kwargs):
20+
async def adelete_installation(event: sansio.Event, gh: GitHubAPI, *args, **kwargs):
2121
installation = await Installation.objects.aget_from_event(event)
2222
await installation.adelete()
2323

2424

2525
@gh.event("installation", action="suspend")
2626
@gh.event("installation", action="unsuspend")
27-
async def toggle_installation_status(
27+
async def atoggle_installation_status(
2828
event: sansio.Event, gh: GitHubAPI, *args, **kwargs
2929
):
3030
installation = await Installation.objects.aget_from_event(event)
@@ -33,14 +33,14 @@ async def toggle_installation_status(
3333

3434

3535
@gh.event("installation", action="new_permissions_accepted")
36-
async def sync_installation_data(event: sansio.Event, gh: GitHubAPI, *args, **kwargs):
36+
async def async_installation_data(event: sansio.Event, gh: GitHubAPI, *args, **kwargs):
3737
installation = await Installation.objects.aget_from_event(event)
3838
installation.data = event.data["installation"]
3939
await installation.asave()
4040

4141

4242
@gh.event("installation_repositories")
43-
async def sync_installation_repositories(
43+
async def async_installation_repositories(
4444
event: sansio.Event, gh: GitHubAPI, *args, **kwargs
4545
):
4646
removed = [repo["id"] for repo in event.data["repositories_removed"]]

src/django_github_app/events/repository.py renamed to src/django_github_app/events/arepository.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
@gh.event("repository", action="renamed")
13-
async def rename_repository(event: sansio.Event, gh: GitHubAPI, *args, **kwargs):
13+
async def arename_repository(event: sansio.Event, gh: GitHubAPI, *args, **kwargs):
1414
repo = await Repository.objects.aget_from_event(event)
1515
repo.full_name = event.data["repository"]["full_name"]
1616
await repo.asave()

tests/events/test_installation.py renamed to tests/events/test_ainstallation.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
from gidgethub.abc import sansio
66
from model_bakery import baker
77

8-
from django_github_app.events.installation import create_installation
9-
from django_github_app.events.installation import delete_installation
10-
from django_github_app.events.installation import sync_installation_data
11-
from django_github_app.events.installation import sync_installation_repositories
12-
from django_github_app.events.installation import toggle_installation_status
8+
from django_github_app.events.ainstallation import acreate_installation
9+
from django_github_app.events.ainstallation import adelete_installation
10+
from django_github_app.events.ainstallation import async_installation_data
11+
from django_github_app.events.ainstallation import async_installation_repositories
12+
from django_github_app.events.ainstallation import atoggle_installation_status
1313
from django_github_app.models import Installation
1414
from django_github_app.models import InstallationStatus
1515
from django_github_app.models import Repository
@@ -18,7 +18,7 @@
1818
pytestmark = [pytest.mark.asyncio, pytest.mark.django_db]
1919

2020

21-
async def test_create_installation(
21+
async def test_acreate_installation(
2222
installation_id, repository_id, override_app_settings
2323
):
2424
data = {
@@ -33,7 +33,7 @@ async def test_create_installation(
3333
event = sansio.Event(data, event="installation", delivery_id="1234")
3434

3535
with override_app_settings(APP_ID=str(data["installation"]["app_id"])):
36-
await create_installation(event, None)
36+
await acreate_installation(event, None)
3737

3838
installation = await Installation.objects.aget(
3939
installation_id=data["installation"]["id"]
@@ -42,7 +42,7 @@ async def test_create_installation(
4242
assert installation.data == data["installation"]
4343

4444

45-
async def test_delete_installation(ainstallation):
45+
async def test_adelete_installation(ainstallation):
4646
installation = await ainstallation
4747
data = {
4848
"installation": {
@@ -51,7 +51,7 @@ async def test_delete_installation(ainstallation):
5151
}
5252
event = sansio.Event(data, event="installation", delivery_id="1234")
5353

54-
await delete_installation(event, None)
54+
await adelete_installation(event, None)
5555

5656
assert not await Installation.objects.filter(
5757
installation_id=data["installation"]["id"]
@@ -65,7 +65,7 @@ async def test_delete_installation(ainstallation):
6565
(InstallationStatus.INACTIVE, "unsuspend", InstallationStatus.ACTIVE),
6666
],
6767
)
68-
async def test_toggle_installation_status_suspend(
68+
async def test_atoggle_installation_status_suspend(
6969
status, action, expected, ainstallation
7070
):
7171
installation = await ainstallation
@@ -82,13 +82,13 @@ async def test_toggle_installation_status_suspend(
8282

8383
assert installation.status != expected
8484

85-
await toggle_installation_status(event, None)
85+
await atoggle_installation_status(event, None)
8686

8787
await installation.arefresh_from_db()
8888
assert installation.status == expected
8989

9090

91-
async def test_sync_installation_data(ainstallation):
91+
async def test_async_installation_data(ainstallation):
9292
installation = await ainstallation
9393

9494
data = {
@@ -100,13 +100,13 @@ async def test_sync_installation_data(ainstallation):
100100

101101
assert installation.data != data
102102

103-
await sync_installation_data(event, None)
103+
await async_installation_data(event, None)
104104

105105
await installation.arefresh_from_db()
106106
assert installation.data == data["installation"]
107107

108108

109-
async def test_sync_installation_repositories(ainstallation):
109+
async def test_async_installation_repositories(ainstallation):
110110
installation = await ainstallation
111111
existing_repo = await sync_to_async(baker.make)(
112112
"django_github_app.Repository",
@@ -140,7 +140,7 @@ async def test_sync_installation_repositories(ainstallation):
140140
repository_id=data["repositories_added"][0]["id"]
141141
).aexists()
142142

143-
await sync_installation_repositories(event, None)
143+
await async_installation_repositories(event, None)
144144

145145
assert not await Repository.objects.filter(
146146
repository_id=data["repositories_removed"][0]["id"]

tests/events/test_repository.py renamed to tests/events/test_arepository.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
from gidgethub import sansio
66
from model_bakery import baker
77

8-
from django_github_app.events.repository import rename_repository
8+
from django_github_app.events.arepository import arename_repository
99
from django_github_app.models import Repository
1010

1111
pytestmark = [pytest.mark.asyncio, pytest.mark.django_db]
1212

1313

14-
async def test_rename_repository(ainstallation, repository_id):
14+
async def test_arename_repository(ainstallation, repository_id):
1515
installation = await ainstallation
1616
repository = await sync_to_async(baker.make)(
1717
"django_github_app.Repository",
@@ -32,7 +32,7 @@ async def test_rename_repository(ainstallation, repository_id):
3232
full_name=data["repository"]["full_name"]
3333
).aexists()
3434

35-
await rename_repository(event, None)
35+
await arename_repository(event, None)
3636

3737
assert await Repository.objects.filter(
3838
full_name=data["repository"]["full_name"]

0 commit comments

Comments
 (0)