Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# Test POST verb without querystring
ext = dapr._get_http_extension('POST')
self.assertEqual(common_v1.HTTPExtension.Verb.POST, ext.verb)
# Test Non-supported http verb
with self.assertRaises(ValueError):
ext = dapr._get_http_extension('')
# Test POST verb with querystring
qs = (
('query1', 'string1'),
('query2', 'string2'),
)
ext = dapr._get_http_extension('POST', qs)
self.assertEqual(common_v1.HTTPExtension.Verb.POST, ext.verb)
for key, val in qs:
self.assertEqual(val, ext.querystring[key])
def test_http_extension(self):
dapr = DaprClient(f'localhost:{self.server_port}')
# Test POST verb without querystring
ext = dapr._get_http_extension('POST')
self.assertEqual(common_v1.HTTPExtension.Verb.POST, ext.verb)
# Test Non-supported http verb
with self.assertRaises(ValueError):
ext = dapr._get_http_extension('')
# Test POST verb with querystring
qs = (
('query1', 'string1'),
('query2', 'string2'),
)
ext = dapr._get_http_extension('POST', qs)
self.assertEqual(common_v1.HTTPExtension.Verb.POST, ext.verb)
for key, val in qs:
self.assertEqual(val, ext.querystring[key])
def _get_http_extension(
self, http_verb: str,
http_querystring: Optional[MetadataTuple] = ()
) -> common_v1.HTTPExtension: # type: ignore
verb = common_v1.HTTPExtension.Verb.Value(http_verb) # type: ignore
http_ext = common_v1.HTTPExtension(verb=verb)
for key, val in http_querystring: # type: ignore
http_ext.querystring[key] = val
return http_ext