Skip to content

Commit 1603628

Browse files
committed
Merge branch 'tickets/DM-17879'
2 parents 358e61e + cebfcf6 commit 1603628

File tree

3 files changed

+74
-1
lines changed

3 files changed

+74
-1
lines changed

CHANGELOG.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22
Change log
33
##########
44

5+
0.1.1 (2019-02-13)
6+
==================
7+
8+
Several fixes:
9+
10+
- ``RegistryApi.put`` was doing a ``PATCH`` behind the scenes. That's fixed now.
11+
- The ``RegistryApi.put``, ``patch``, and ``delete`` methods weren't returning data. That's fixed now as well.
12+
- All of the RegistryApi's low-level HTTP methods have more thorough unit testing now to avoid these issues in the future.
13+
14+
:jirab:`DM-17879`
15+
516
0.1.0 (2019-01-30)
617
==================
718

kafkit/registry/sansio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ async def patch(self, url, url_vars=dict(), *, data):
252252
wrong with the server itself.
253253
"""
254254
data = await self._make_request("PATCH", url, url_vars, data)
255+
return data
255256

256257
async def put(self, url, url_vars=dict(), data=b""):
257258
"""Send an HTTP PUT request.
@@ -285,7 +286,8 @@ async def put(self, url, url_vars=dict(), data=b""):
285286
Raised if the server returns a 5XX status because something is
286287
wrong with the server itself.
287288
"""
288-
data = await self._make_request("PATCH", url, url_vars, data)
289+
data = await self._make_request("PUT", url, url_vars, data)
290+
return data
289291

290292
async def delete(self, url, url_vars=dict(), *, data=b""):
291293
"""Send an HTTP DELETE request.
@@ -320,6 +322,7 @@ async def delete(self, url, url_vars=dict(), *, data=b""):
320322
wrong with the server itself.
321323
"""
322324
data = await self._make_request("DELETE", url, url_vars, data)
325+
return data
323326

324327
@staticmethod
325328
def _prep_schema(schema):

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)