Skip to content

Commit 8409296

Browse files
jliunyuedenhill
authored andcommitted
Fix failed test cases for Schema Registry
1 parent 3ddbd59 commit 8409296

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

tests/avro/test_cached_client.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ class TestCacheSchemaRegistryClient(unittest.TestCase):
3232
def setUp(self):
3333
self.server = mock_registry.ServerThread(0)
3434
self.server.start()
35-
self.client = CachedSchemaRegistryClient('http://127.0.0.1:' + str(self.server.server.server_port))
35+
self.client = CachedSchemaRegistryClient({
36+
'url': 'http://127.0.0.1:' + str(self.server.server.server_port),
37+
})
3638

3739
def tearDown(self):
3840
self.server.shutdown()
@@ -140,19 +142,25 @@ def hash_func(self):
140142

141143
def test_cert_no_key(self):
142144
with self.assertRaises(ValueError):
143-
self.client = CachedSchemaRegistryClient(url='https://127.0.0.1:65534',
144-
cert_location='/path/to/cert')
145+
self.client = CachedSchemaRegistryClient({
146+
'url': 'https://127.0.0.1:65534',
147+
'ssl.certificate.location': '/path/to/cert',
148+
})
145149

146150
def test_cert_with_key(self):
147-
self.client = CachedSchemaRegistryClient(url='https://127.0.0.1:65534',
148-
cert_location='/path/to/cert',
149-
key_location='/path/to/key')
151+
self.client = CachedSchemaRegistryClient({
152+
'url': 'https://127.0.0.1:65534',
153+
'ssl.certificate.location': '/path/to/cert',
154+
'ssl.key.location': '/path/to/key'
155+
})
150156
self.assertTupleEqual(('/path/to/cert', '/path/to/key'), self.client._session.cert)
151157

152-
def test_cert_path(self):
153-
self.client = CachedSchemaRegistryClient(url='https://127.0.0.1:65534',
154-
ca_location='/path/to/ca')
155-
self.assertEqual('/path/to/ca', self.client._session.verify)
158+
def test_key_no_cert(self):
159+
with self.assertRaises(ValueError):
160+
self.client = CachedSchemaRegistryClient({
161+
'url': 'https://127.0.0.1:65534',
162+
'ssl.key.location': '/path/to/key'
163+
})
156164

157165
def test_context(self):
158166
with self.client as c:
@@ -177,8 +185,9 @@ def test_empty_url(self):
177185

178186
def test_invalid_type_url(self):
179187
with self.assertRaises(TypeError):
180-
self.client = CachedSchemaRegistryClient(
181-
url=1)
188+
self.client = CachedSchemaRegistryClient({
189+
'url': 1
190+
})
182191

183192
def test_invalid_type_url_dict(self):
184193
with self.assertRaises(TypeError):

0 commit comments

Comments
 (0)