MCPcopy Create free account
hub / github.com/FDio/vpp / VppPapiProvider

Class VppPapiProvider

test/vpp_papi_provider.py:226–1178  ·  view source on GitHub ↗

VPP-api provider using vpp-papi @property hook: hook object providing before and after api/cli hooks

Source from the content-addressed store, hash-verified

224
225
226class VppPapiProvider(object):
227 """VPP-api provider using vpp-papi
228
229 @property hook: hook object providing before and after api/cli hooks
230 """
231
232 _negative = object()
233
234 ansi_escape = re.compile(r"\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])")
235
236 def __init__(self, name, test_class, read_timeout):
237 self.hook = Hook(test_class)
238 self.name = name
239 self.test_class = test_class
240 self._expect_api_retval = None
241 self._expect_stack = []
242
243 self.vpp = VPPApiClient(
244 apidir=config.extern_apidir + [config.vpp_install_dir],
245 logger=test_class.logger,
246 read_timeout=read_timeout,
247 use_socket=True,
248 server_address=test_class.get_api_sock_path(),
249 )
250 self._events = queue.Queue()
251
252 def __enter__(self):
253 return self
254
255 def assert_negative_api_retval(self):
256 """Expect API failure - used with with, e.g.::
257
258 with self.vapi.assert_negative_api_retval():
259 self.vapi.<api call expected to fail>
260
261 ..
262 """
263 self._expect_stack.append(self._expect_api_retval)
264 self._expect_api_retval = self._negative
265 return self
266
267 def assert_known_api_retval(self, retvals: list[int]):
268 """Expect API to have a certain return value used with with, e.g.::
269
270 with self.vapi.assert_known_api_retval(retvals=[0,-165]):
271 self.vapi.<api call expected to succeed>
272
273 :note: this is useful only inside another with block
274 as success is the default expected value
275 """
276 self._expect_stack.append(self._expect_api_retval)
277 self._expect_api_retval = retvals
278 return self
279
280 def assert_zero_api_retval(self):
281 """Expect API success - used with with, e.g.::
282
283 with self.vapi.assert_negative_api_retval():

Callers 2

setUpClassMethod · 0.90
setUpClassMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected