11
11
from django .http import JsonResponse
12
12
from django .utils import timezone
13
13
from gidgethub import sansio
14
+ from gidgethub .abc import GitHubAPI
14
15
from model_bakery import baker
15
16
16
17
from django_github_app .github import AsyncGitHubAPI
@@ -75,7 +76,9 @@ def test_router():
75
76
GitHubRouter ._routers .remove (router .router )
76
77
77
78
78
- class TestWebhookView (BaseWebhookView ):
79
+ class WebhookView (BaseWebhookView [GitHubAPI ]):
80
+ github_api_class = GitHubAPI
81
+
79
82
def post (self , request ):
80
83
return JsonResponse ({})
81
84
@@ -87,7 +90,7 @@ def test_get_event(self, webhook_request):
87
90
delivery_id = 4321
88
91
89
92
request = webhook_request (event_type , body , delivery_id )
90
- view = TestWebhookView ()
93
+ view = WebhookView ()
91
94
event = view .get_event (request )
92
95
93
96
assert isinstance (event , sansio .Event )
@@ -98,7 +101,7 @@ def test_get_event(self, webhook_request):
98
101
# @pytest.mark.parametrize("github_api_class", [AsyncGitHubAPI, SyncGitHubAPI])
99
102
# def test_get_github_api_async(self, github_api_class, installation):
100
103
def test_get_github_api_async (self , installation ):
101
- view = TestWebhookView ()
104
+ view = WebhookView ()
102
105
view .github_api_class = AsyncGitHubAPI
103
106
104
107
gh = view .get_github_api (installation )
@@ -107,14 +110,14 @@ def test_get_github_api_async(self, installation):
107
110
assert gh .installation_id == installation .installation_id
108
111
109
112
def test_get_github_api_sync (self , installation ):
110
- view = TestWebhookView ()
113
+ view = WebhookView ()
111
114
view .github_api_class = SyncGitHubAPI
112
115
113
116
with pytest .raises (NotImplementedError ):
114
117
view .get_github_api (installation )
115
118
116
119
def test_get_response (self , webhook_request ):
117
- view = TestWebhookView ()
120
+ view = WebhookView ()
118
121
119
122
response = view .get_response (baker .make ("django_github_app.EventLog" ))
120
123
0 commit comments