userver: pytest_userver.client.Client Class Reference
Loading...
Searching...
No Matches
pytest_userver.client.Client Class Reference

Detailed Description

Asyncio userver client, typically retrieved from plugins.service_client.service_client fixture.

Compatible with werkzeug interface.

Definition at line 1065 of file client.py.

+ Inheritance diagram for pytest_userver.client.Client:
+ Collaboration diagram for pytest_userver.client.Client:

Public Member Functions

 run_periodic_task (self, name)
 
None suspend_periodic_tasks (self, typing.List[str] names)
 
None resume_periodic_tasks (self, typing.List[str] names)
 
None resume_all_periodic_tasks (self)
 
None write_cache_dumps (self, typing.List[str] names, *testsuite_skip_prepare=False)
 
None read_cache_dumps (self, typing.List[str] names, *testsuite_skip_prepare=False)
 
None run_task (self, str name)
 
None run_distlock_task (self, str name)
 
None reset_metrics (self)
 Calls ResetMetric(metric); for each metric that has such C++ function.
 
typing.Dict[str, typing.List[typing.Dict[str, str]]] metrics_portability (self, *typing.Optional[str] prefix=None)
 Reports metrics related issues that could be encountered on different monitoring systems.
 
typing.List[str] list_tasks (self)
 
 spawn_task (self, str name)
 
 capture_logs (self, *str log_level='DEBUG', bool testsuite_skip_prepare=False)
 Captures logs from the service.
 
 log_flush (self, typing.Optional[str] logger_name=None)
 Flush service logs.
 
None invalidate_caches (self, *bool clean_update=True, typing.Optional[typing.List[str]] cache_names=None, bool testsuite_skip_prepare=False)
 Send request to service to update caches.
 
typing.Dict[str, typing.Any] tests_control (self, *args, **kwargs)
 
None update_server_state (self)
 Update service-side state through http call to 'tests/control':
 
None enable_testpoints (self, *args, **kwargs)
 Send list of handled testpoint pats to service.
 
typing.Dict[str, typing.Any] get_dynamic_config_defaults (self)
 
- Public Member Functions inherited from pytest_userver.client.ClientWrapper
 __init__ (self, client)
 
http.ClientResponse post (self, str path, annotations.JsonAnyOptional json=None, typing.Any data=None, typing.Optional[typing.Dict[str, str]] params=None, typing.Optional[str] bearer=None, typing.Optional[str] x_real_ip=None, typing.Optional[typing.Dict[str, str]] headers=None, **kwargs)
 Make a HTTP POST request.
 
http.ClientResponse put (self, path, annotations.JsonAnyOptional json=None, typing.Any data=None, typing.Optional[typing.Dict[str, str]] params=None, typing.Optional[str] bearer=None, typing.Optional[str] x_real_ip=None, typing.Optional[typing.Dict[str, str]] headers=None, **kwargs)
 Make a HTTP PUT request.
 
http.ClientResponse patch (self, path, annotations.JsonAnyOptional json=None, typing.Any data=None, typing.Optional[typing.Dict[str, str]] params=None, typing.Optional[str] bearer=None, typing.Optional[str] x_real_ip=None, typing.Optional[typing.Dict[str, str]] headers=None, **kwargs)
 Make a HTTP PATCH request.
 
http.ClientResponse get (self, str path, typing.Optional[typing.Dict[str, str]] headers=None, typing.Optional[str] bearer=None, typing.Optional[str] x_real_ip=None, **kwargs)
 Make a HTTP GET request.
 
http.ClientResponse delete (self, str path, typing.Optional[typing.Dict[str, str]] headers=None, typing.Optional[str] bearer=None, typing.Optional[str] x_real_ip=None, **kwargs)
 Make a HTTP DELETE request.
 
http.ClientResponse options (self, str path, typing.Optional[typing.Dict[str, str]] headers=None, typing.Optional[str] bearer=None, typing.Optional[str] x_real_ip=None, **kwargs)
 Make a HTTP OPTIONS request.
 
http.ClientResponse request (self, str http_method, str path, **kwargs)
 Make a HTTP request with the specified method.
 

Static Public Attributes

 PeriodicTaskFailed = PeriodicTaskFailed
 
 TestsuiteActionFailed = TestsuiteActionFailed
 
 TestsuiteTaskNotFound = TestsuiteTaskNotFound
 
 TestsuiteTaskConflict = TestsuiteTaskConflict
 
 TestsuiteTaskFailed = TestsuiteTaskFailed
 

Protected Member Functions

typing.Awaitable[http.ClientResponse] _wrap_client_response (self, aiohttp.ClientResponse response)
 

Additional Inherited Members

- Protected Attributes inherited from pytest_userver.client.ClientWrapper
 _client
 

Member Function Documentation

◆ _wrap_client_response()

typing.Awaitable[http.ClientResponse] pytest_userver.client.Client._wrap_client_response ( self,
aiohttp.ClientResponse response )
protected

Reimplemented from pytest_userver.client.ClientWrapper.

Definition at line 1082 of file client.py.

◆ capture_logs()

pytest_userver.client.Client.capture_logs ( self,
*str log_level = 'DEBUG',
bool testsuite_skip_prepare = False )

Captures logs from the service.

Parameters
log_levelDo not capture logs below this level.
See also
testsuite_logs_capture

Definition at line 1150 of file client.py.

◆ enable_testpoints()

None pytest_userver.client.Client.enable_testpoints ( self,
* args,
** kwargs )

Send list of handled testpoint pats to service.

For these paths service will no more skip http calls from TESTPOINT(...) macro.

Parameters
no_auto_cache_cleanupprevent automatic cache cleanup. When calling service client first time in scope of current test, client makes additional http call to tests/control to update caches, to get rid of data from previous test.

Definition at line 1217 of file client.py.

◆ get_dynamic_config_defaults()

typing.Dict[str, typing.Any] pytest_userver.client.Client.get_dynamic_config_defaults ( self)

Definition at line 1230 of file client.py.

◆ invalidate_caches()

None pytest_userver.client.Client.invalidate_caches ( self,
*bool clean_update = True,
typing.Optional[typing.List[str]] cache_names = None,
bool testsuite_skip_prepare = False )

Send request to service to update caches.

Parameters
clean_updateif False, service will do a faster incremental update of caches whenever possible.
cache_nameswhich caches specifically should be updated; update all if None.
testsuite_skip_prepareif False, service will automatically do update_server_state().

Definition at line 1174 of file client.py.

◆ list_tasks()

typing.List[str] pytest_userver.client.Client.list_tasks ( self)

Definition at line 1144 of file client.py.

◆ log_flush()

pytest_userver.client.Client.log_flush ( self,
typing.Optional[str] logger_name = None )

Flush service logs.

Definition at line 1167 of file client.py.

◆ metrics_portability()

typing.Dict[str, typing.List[typing.Dict[str, str]]] pytest_userver.client.Client.metrics_portability ( self,
*typing.Optional[str] prefix = None )

Reports metrics related issues that could be encountered on different monitoring systems.

See also
utils::statistics::GetPortabilityInfo

Definition at line 1133 of file client.py.

◆ read_cache_dumps()

None pytest_userver.client.Client.read_cache_dumps ( self,
typing.List[str] names,
* testsuite_skip_prepare = False )

Definition at line 1114 of file client.py.

◆ reset_metrics()

None pytest_userver.client.Client.reset_metrics ( self)

Calls ResetMetric(metric); for each metric that has such C++ function.

Definition at line 1127 of file client.py.

◆ resume_all_periodic_tasks()

None pytest_userver.client.Client.resume_all_periodic_tasks ( self)

Definition at line 1102 of file client.py.

◆ resume_periodic_tasks()

None pytest_userver.client.Client.resume_periodic_tasks ( self,
typing.List[str] names )

Definition at line 1098 of file client.py.

◆ run_distlock_task()

None pytest_userver.client.Client.run_distlock_task ( self,
str name )

Definition at line 1124 of file client.py.

◆ run_periodic_task()

pytest_userver.client.Client.run_periodic_task ( self,
name )

Definition at line 1090 of file client.py.

◆ run_task()

None pytest_userver.client.Client.run_task ( self,
str name )

Definition at line 1121 of file client.py.

◆ spawn_task()

pytest_userver.client.Client.spawn_task ( self,
str name )

Definition at line 1147 of file client.py.

◆ suspend_periodic_tasks()

None pytest_userver.client.Client.suspend_periodic_tasks ( self,
typing.List[str] names )

Definition at line 1094 of file client.py.

◆ tests_control()

typing.Dict[str, typing.Any] pytest_userver.client.Client.tests_control ( self,
* args,
** kwargs )

Definition at line 1199 of file client.py.

◆ update_server_state()

None pytest_userver.client.Client.update_server_state ( self)

Update service-side state through http call to 'tests/control':

  • clear dirty (from other tests) caches
  • set service-side mocked time,
  • resume / suspend periodic tasks
  • enable testpoints If service is up-to-date, does nothing.

Definition at line 1205 of file client.py.

◆ write_cache_dumps()

None pytest_userver.client.Client.write_cache_dumps ( self,
typing.List[str] names,
* testsuite_skip_prepare = False )

Definition at line 1106 of file client.py.

Member Data Documentation

◆ PeriodicTaskFailed

pytest_userver.client.Client.PeriodicTaskFailed = PeriodicTaskFailed
static

Definition at line 1076 of file client.py.

◆ TestsuiteActionFailed

pytest_userver.client.Client.TestsuiteActionFailed = TestsuiteActionFailed
static

Definition at line 1077 of file client.py.

◆ TestsuiteTaskConflict

pytest_userver.client.Client.TestsuiteTaskConflict = TestsuiteTaskConflict
static

Definition at line 1079 of file client.py.

◆ TestsuiteTaskFailed

pytest_userver.client.Client.TestsuiteTaskFailed = TestsuiteTaskFailed
static

Definition at line 1080 of file client.py.

◆ TestsuiteTaskNotFound

pytest_userver.client.Client.TestsuiteTaskNotFound = TestsuiteTaskNotFound
static

Definition at line 1078 of file client.py.


The documentation for this class was generated from the following file: