@@ -65,8 +65,9 @@ async def test_update_repo(tmp_path_factory):
65
65
assert dest_commit == src_commit
66
66
67
67
68
- async def test_github_webhook_errors (aiohttp_client , monkeypatch ):
68
+ async def test_github_webhook_errors (aiohttp_client , monkeypatch , tmp_path ):
69
69
"""Test invalid inputs to webhook."""
70
+ monkeypatch .setenv ('SITE_DIR' , str (tmp_path ))
70
71
client = await aiohttp_client (create_app ())
71
72
72
73
# Only /gh/<repo-name> exists.
@@ -121,6 +122,14 @@ async def test_github_webhook_errors(aiohttp_client, monkeypatch):
121
122
assert resp .status == 400
122
123
assert 'incorrect repository' in await resp .text ()
123
124
125
+ # Fields provided, but invalid.
126
+ resp = await client .post (
127
+ '/gh/non-existent-repo' , headers = valid_headers ,
128
+ data = '{"sender": {"login": "QuLogic"}, "repository":'
129
+ ' {"name": "..", "owner": {"login": "matplotlib"}}}' )
130
+ assert resp .status == 400
131
+ assert 'incorrect repository' in await resp .text ()
132
+
124
133
# Problem on our side.
125
134
resp = await client .post (
126
135
'/gh/non-existent' ,
@@ -134,12 +143,12 @@ async def test_github_webhook_errors(aiohttp_client, monkeypatch):
134
143
135
144
async def test_github_webhook_valid (aiohttp_client , monkeypatch , tmp_path ):
136
145
"""Test valid input to webhook."""
146
+ monkeypatch .setenv ('SITE_DIR' , str (tmp_path ))
137
147
client = await aiohttp_client (create_app ())
138
148
139
149
# Do no actual work, since that's tested above.
140
150
monkeypatch .setattr (webhook , 'verify_signature' ,
141
151
mock .Mock (verify_signature , return_value = True ))
142
- monkeypatch .setenv ('SITE_DIR' , str (tmp_path ))
143
152
ur_mock = mock .Mock (update_repo , return_value = None )
144
153
monkeypatch .setattr (webhook , 'update_repo' , ur_mock )
145
154
0 commit comments