Skip to content

Commit 1de4ec1

Browse files
committed
Add more thorough testing of http methods
1 parent b94530e commit 1de4ec1

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

tests/test_registry_sansio.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ async def test_registryapi_get_empty():
121121
# Check headers
122122
assert client.headers['accept'] == make_headers()['accept']
123123
assert client.headers['content-length'] == '0'
124+
assert client.method == 'GET'
124125

125126

126127
@pytest.mark.asyncio
@@ -135,6 +136,64 @@ async def test_registryapi_get_json():
135136
url_vars={'subject': 'helloworld'})
136137

137138
assert response == expected_data
139+
assert client.method == 'GET'
140+
141+
142+
@pytest.mark.asyncio
143+
async def test_registryapi_post():
144+
"""Test RegistryApi.post().
145+
"""
146+
expected_data = {'key': 'value'}
147+
client = MockRegistryApi(
148+
url='http://registry:8081',
149+
body=json.dumps(expected_data).encode('utf-8'))
150+
response = await client.post('/a{/b}', url_vars={'b': 'hello'}, data={})
151+
152+
assert response == expected_data
153+
assert client.method == 'POST'
154+
assert client.url == 'http://registry:8081/a/hello'
155+
156+
157+
@pytest.mark.asyncio
158+
async def test_registryapi_patch():
159+
"""Test RegistryApi.patch().
160+
"""
161+
expected_data = {'key': 'value'}
162+
client = MockRegistryApi(
163+
url='http://registry:8081',
164+
body=json.dumps(expected_data).encode('utf-8'))
165+
response = await client.patch('/a{/b}', url_vars={'b': 'hello'}, data={})
166+
167+
assert response == expected_data
168+
assert client.method == 'PATCH'
169+
assert client.url == 'http://registry:8081/a/hello'
170+
171+
172+
@pytest.mark.asyncio
173+
async def test_registryapi_put():
174+
"""Test RegistryApi.put().
175+
"""
176+
expected_data = {'key': 'value'}
177+
client = MockRegistryApi(
178+
url='http://registry:8081',
179+
body=json.dumps(expected_data).encode('utf-8'))
180+
response = await client.put('/a{/b}', url_vars={'b': 'hello'}, data={})
181+
182+
assert response == expected_data
183+
assert client.method == 'PUT'
184+
assert client.url == 'http://registry:8081/a/hello'
185+
186+
187+
@pytest.mark.asyncio
188+
async def test_registryapi_delete():
189+
"""Test RegistryApi.put().
190+
"""
191+
client = MockRegistryApi(
192+
url='http://registry:8081')
193+
await client.delete('/a{/b}', url_vars={'b': 'hello'})
194+
195+
assert client.method == 'DELETE'
196+
assert client.url == 'http://registry:8081/a/hello'
138197

139198

140199
@pytest.mark.asyncio

0 commit comments

Comments
 (0)