@@ -65,8 +65,9 @@ async def test_update_repo(tmp_path_factory):
6565 assert dest_commit == src_commit
6666
6767
68- async def test_github_webhook_errors (aiohttp_client , monkeypatch ):
68+ async def test_github_webhook_errors (aiohttp_client , monkeypatch , tmp_path ):
6969 """Test invalid inputs to webhook."""
70+ monkeypatch .setenv ('SITE_DIR' , str (tmp_path ))
7071 client = await aiohttp_client (create_app ())
7172
7273 # Only /gh/<repo-name> exists.
@@ -121,6 +122,14 @@ async def test_github_webhook_errors(aiohttp_client, monkeypatch):
121122 assert resp .status == 400
122123 assert 'incorrect repository' in await resp .text ()
123124
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+
124133 # Problem on our side.
125134 resp = await client .post (
126135 '/gh/non-existent' ,
@@ -134,12 +143,12 @@ async def test_github_webhook_errors(aiohttp_client, monkeypatch):
134143
135144async def test_github_webhook_valid (aiohttp_client , monkeypatch , tmp_path ):
136145 """Test valid input to webhook."""
146+ monkeypatch .setenv ('SITE_DIR' , str (tmp_path ))
137147 client = await aiohttp_client (create_app ())
138148
139149 # Do no actual work, since that's tested above.
140150 monkeypatch .setattr (webhook , 'verify_signature' ,
141151 mock .Mock (verify_signature , return_value = True ))
142- monkeypatch .setenv ('SITE_DIR' , str (tmp_path ))
143152 ur_mock = mock .Mock (update_repo , return_value = None )
144153 monkeypatch .setattr (webhook , 'update_repo' , ur_mock )
145154
0 commit comments