Fixtures to use with testsuite.
Namespaces | |
| namespace | pytest_userver.plugins.core |
| Python plugin that provides core fixtures for functional tests with testsuite; see Functional service tests (testsuite) for an introduction. | |
| namespace | pytest_userver.plugins.grpc |
| Python plugin that provides gRPC fixtures for functional tests with testsuite; see Functional service tests (testsuite) for an introduction. | |
| namespace | pytest_userver.plugins.metrics |
| Provides a nicer pytest diff (via testsuite's CompareVisitor mechanism) for failing == comparisons that involve MetricsSnapshot. | |
| namespace | pytest_userver.plugins.sql_coverage |
| Plugin that imports the required fixtures for checking SQL/YQL coverage. | |
| namespace | pytest_userver.plugins.ydb |
| pytest plugin that provides YDB fixtures for functional tests with testsuite; see YDB for an introduction. | |
Functions | |
| CreateDaemonScope | testsuite.daemons.pytest_plugin.create_daemon_scope (_DaemonStore _global_daemon_store, ServiceSpawnerFactory service_spawner_factory) |
| Create daemon scope for daemon with command to start. | |
| testsuite.daemons.pytest_plugin.register_daemon_scope (_DaemonStore _global_daemon_store) | |
| Context manager that registers service process session. | |
| dict[str, str] | testsuite.daemons.pytest_plugin.service_client_default_headers () |
| Default service client headers. | |
| types.YieldFixture[dict[str, Any]] | testsuite.daemons.pytest_plugin.service_client_options (pytestconfig, aiohttp.ClientSession service_client_session, fixture_types.MockserverFixture mockserver) |
| Returns service client options dictionary. | |
| classes.DatabasesDict | testsuite.databases.clickhouse.pytest_plugin.clickhouse_local () |
| Use to override databases configuration. | |
| typing.AsyncGenerator[classes.KafkaProducer, None] | testsuite.databases.kafka.pytest_plugin.kafka_producer (_kafka_global_producer) |
| Per test Kafka producer instance. | |
| typing.AsyncGenerator[classes.KafkaConsumer, None] | testsuite.databases.kafka.pytest_plugin.kafka_consumer (_kafka_global_consumer) |
| Per test Kafka consumer instance. | |
| dict[str, int] | testsuite.databases.kafka.pytest_plugin.kafka_custom_topics () |
| Redefine this fixture to pass your custom dictionary of topics' settings. | |
| classes.BootstrapServers | testsuite.databases.kafka.pytest_plugin.kafka_local () |
| Override to use custom local cluster bootstrap servers. | |
| CollectionWrapper | testsuite.databases.mongo.pytest_plugin.mongodb (mongodb_init, CollectionWrapper _mongodb_local) |
| Returns MongoDB collections wrapper for the test. | |
| tuple[str,...] | testsuite.databases.mongo.pytest_plugin.mongo_extra_connections () |
| Override this if you need to access mongo connections besides those defined in mongo_connections fixture. | |
| tuple[str,...] | testsuite.databases.mongo.pytest_plugin.mongodb_collections (mongodb_settings) |
| Override this to enable access to named collections within test module. | |
| tuple[str,...] | testsuite.databases.mongo.pytest_plugin.mongo_schema_extra_directories () |
Override to use collection schemas besides those defined by mongo_schema_directory fixture. | |
| None | testsuite.databases.mongo.pytest_plugin.mongodb_init (request, verify_file_paths, pathlib.Path static_dir, _mongodb_local, _mongo_thread_pool, _mongo_create_indexes, _mongo_query_loader) |
| Populate mongodb with fixture data. | |
| dict[str, control.ConnectionWrapper] | testsuite.databases.mysql.pytest_plugin.mysql (_mysql, _mysql_apply) |
| MySQL fixture. | |
| classes.DatabasesDict | testsuite.databases.mysql.pytest_plugin.mysql_local () |
| Use to override databases configuration. | |
| dict[str, control.PgDatabaseWrapper] | testsuite.databases.pgsql.pytest_plugin.pgsql (_pgsql, pgsql_apply) |
| Returns str to testsuite.databases.pgsql.control.PgDatabaseWrapper dictionary. | |
| typing.Callable[[list[discover.PgShardedDatabase]], ServiceLocalConfig,] | testsuite.databases.pgsql.pytest_plugin.pgsql_local_create (_pgsql_control, pgsql_cleanup_exclude_tables) |
| Creates pgsql configuration. | |
| ServiceLocalConfig | testsuite.databases.pgsql.pytest_plugin.pgsql_local (pgsql_local_create) |
| Configures local pgsql instance. | |
| None | testsuite.databases.pgsql.pytest_plugin.pgsql_apply (ServiceLocalConfig _pgsql, load, bool pgsql_background_truncate_enabled, bool pgsql_parallelization_enabled, _pgsql_apply_queries) |
| Initialize PostgreSQL database with data. | |
| testsuite.databases.redis.pytest_plugin.redis_store (pytestconfig, _redis_store, _redis_execute_commands_from_file) | |
| Returns a Redis client for the test store. | |
| types.YieldFixture[server.MockserverFixture] | testsuite.mockserver.pytest_plugin.mockserver (server.Server _mockserver, mockserver_create_session) |
| Returns per-test mockserver client. | |
| classes.MockserverInfo | testsuite.mockserver.pytest_plugin.mockserver_info (classes.MockserverSocket _mockserver_socket) |
| Returns mockserver information object. | |
| testsuite.plugins.asyncexc.asyncexc_append (_asyncexc) | |
| Register background exception. | |
| testsuite.plugins.asyncexc.asyncexc_check (_asyncexc) | |
| Raise in case there are background exceptions. | |
| testsuite.plugins.asyncio.plugin_legacy.event_loop () | |
| Overrides pytest-asyncio internal event_loop fixture. | |
| LoadFixture | testsuite.plugins.common.load (GetFilePathFixture get_file_path) |
| Returns a function that loads a static file as text. | |
| LoadBinaryFixture | testsuite.plugins.common.load_binary (GetFilePathFixture get_file_path) |
| Returns a function that loads a static file as bytes. | |
| LoadJsonFixture | testsuite.plugins.common.load_json (LoadFixture load, JsonLoadsFixture json_loads) |
| Returns a function that loads a static file as JSON. | |
| LoadYamlFixture | testsuite.plugins.common.load_yaml (LoadFixture load) |
| Returns a function that loads a static file as YAML. | |
| pathlib.Path | testsuite.plugins.common.static_dir (testsuite_request_directory) |
| Static directory related to test path. | |
| tuple[pathlib.Path,...] | testsuite.plugins.common.initial_data_path () |
| Use this fixture to override base static search path. | |
| testsuite.plugins.common.object_substitute (object_hook) | |
| Perform object substitution as in load_json. | |
| MockedTime | testsuite.plugins.mocked_time.mocked_time (bool _mocked_time_enabled, datetime.datetime now) |
| typing.Callable[[], int] | testsuite.plugins.network.get_free_port (_get_free_port_sock_storing, _get_free_port_range_based) |
| Returns an ephemeral TCP port that is free for IPv4 and for IPv6. | |
| testsuite.plugins.testpoint.testpoint_checker_factory () | |
| Testpoint checker factory fixture. | |
| TestpointFixture | testsuite.plugins.testpoint.testpoint (server.MockserverFixture mockserver, testpoint_checker_factory) |
| Testpoint fixture returns testpoint session instance that works as decorator that registers testpoint handler. | |
| testsuite.plugins.tracing.testsuite_traceid_generator () | |
| Fill free to override this fixture with our own. | |
| str | testsuite.plugins.tracing.testsuite_trace_id (testsuite_traceid_generator, _testsuite_traceid_history) |
| Testcase trace id. | |
| TraceidManager | testsuite.plugins.tracing.testsuite_traceid_manager (str testsuite_trace_id, _testsuite_traceid_history) |
| TraceidManager associated with current testcase. | |
| pytest_userver.plugins.asyncio_socket._asyncio_socket (asyncio_loop) | |
| Factory for asyncio-compatible sockets used in TCP tests. | |
| pathlib.Path | pytest_userver.plugins.base.service_source_dir (pytestconfig) |
| Returns the path to the service source directory that is set by command line --service-source-dir option. | |
| pathlib.Path | pytest_userver.plugins.base.build_dir (pytestconfig) |
| Returns the build directory set by command line --build-dir option. | |
| pathlib.Path | pytest_userver.plugins.base.service_binary (pytestconfig) |
| Returns the path to service binary set by command line --service-binary option. | |
| int | pytest_userver.plugins.base.service_port (pytestconfig, _original_service_config, choose_free_port) |
| Returns the main listener port number of the service set by command line --service-port option. | |
| int | pytest_userver.plugins.base.monitor_port (pytestconfig, _original_service_config, choose_free_port) |
| Returns the monitor listener port number of the service set by command line --monitor-port option. | |
| bool | pytest_userver.plugins.base.congestion_control_fake_mode () |
| Returns congestion control fake-mode value. | |
| Callable[[int|None], int] | pytest_userver.plugins.base.choose_free_port (pytestconfig, get_free_port, _testsuite_socket_cleanup, _testsuite_default_af) |
| A function that chooses a free port based on the optional hint given in the parameter. | |
| InvalidationState | pytest_userver.plugins.caches.cache_invalidation_state () |
| A fixture for notifying the service of changes in cache data sources. | |
| CacheControl | pytest_userver.plugins.caches.userver_cache_control (_userver_cache_control_context, _userver_cache_fixtures, request) |
| Userver cache control handler. | |
| pathlib.Path | pytest_userver.plugins.config.service_config_path (pytestconfig, service_binary) |
| Returns the path to service.yaml file set by command line --service-config option. | |
| pathlib.Path | pytest_userver.plugins.config.db_dump_schema_path (service_binary, service_tmpdir) |
| Runs the service binary with --dump-db-schema argument, dumps the 0_db_schema.sql file with database schema and returns path to it. | |
| pathlib.Path|None | pytest_userver.plugins.config.service_config_vars_path (pytestconfig) |
| Returns the path to config_vars.yaml file set by command line --service-config-vars option. | |
| pathlib.Path|None | pytest_userver.plugins.config.service_secdist_path (pytestconfig) |
| Returns the path to secure_data.json file set by command line --service-secdist option. | |
| pathlib.Path | pytest_userver.plugins.config.config_fallback_path (pytestconfig) |
| Returns the path to dynamic config fallback file set by command line --config-fallback option. | |
| pytest_userver.plugins.config.service_tmpdir (service_binary, tmp_path_factory) | |
| Returns the path for temporary files. | |
| pathlib.Path | pytest_userver.plugins.config.service_config_path_temp (service_tmpdir, service_config, service_config_yaml, service_config_vars) |
| Dumps the contents of the service_config_yaml and service_config_vars into a static config for testsuite and returns the path to the config file. | |
| dict | pytest_userver.plugins.config.service_config_yaml (_service_config_hooked) |
| Returns the static config values after the USERVER_CONFIG_HOOKS were applied (if any). | |
| dict | pytest_userver.plugins.config.service_config_vars (_service_config_hooked) |
| Returns the static config variables (config_vars.yaml) values after the USERVER_CONFIG_HOOKS were applied (if any). | |
| Callable[[Any, dict], Any] | pytest_userver.plugins.config.substitute_config_vars (service_env) |
| A function that takes config_yaml, config_vars and applies all substitutions just like the service would. | |
| dict | pytest_userver.plugins.config.service_config (service_config_yaml, service_config_vars, substitute_config_vars) |
| Returns the static config values after the USERVER_CONFIG_HOOKS were applied (if any) and with all the '$', environment and fallback variables substituted. | |
| ServiceConfigPatch | pytest_userver.plugins.config.userver_config_substitutions (_service_config_substitution_vars) |
| Replaces substitution vars in all strings within config_vars using string.Template.substitute. | |
| ServiceConfigPatch | pytest_userver.plugins.config.userver_config_http_server (service_port, monitor_port) |
| Returns a function that adjusts the static configuration file for testsuite. | |
| list[str] | pytest_userver.plugins.config.allowed_url_prefixes_extra () |
| By default, userver HTTP client is only allowed to talk to mockserver when running in testsuite. | |
| list[str] | pytest_userver.plugins.config.allowed_url_prefixes (mockserver_info, mockserver_ssl_info, allowed_url_prefixes_extra) |
| Returns final list of allowed urls prefixes when running in testsuite. | |
| ServiceConfigPatch | pytest_userver.plugins.config.userver_config_http_client (allowed_url_prefixes) |
| Returns a function that adjusts the static configuration file for testsuite. | |
| str | pytest_userver.plugins.config.userver_default_log_level () |
| Default log level to use in userver if no command line option was provided. | |
| str | pytest_userver.plugins.config.userver_log_level (pytestconfig, userver_default_log_level) |
| Returns –service-log-level value if provided, otherwise returns userver_default_log_level() value from fixture. | |
| ServiceConfigPatch | pytest_userver.plugins.config.userver_config_logging (userver_log_level, _service_logfile_path) |
| Returns a function that adjusts the static configuration file for testsuite. | |
| ServiceConfigPatch | pytest_userver.plugins.config.userver_config_logging_otlp () |
| Returns a function that adjusts the static configuration file for testsuite. | |
| ServiceConfigPatch | pytest_userver.plugins.config.userver_config_testsuite (pytestconfig, mockserver_info) |
| Returns a function that adjusts the static configuration file for testsuite. | |
| ServiceConfigPatch | pytest_userver.plugins.config.userver_config_secdist (service_secdist_path) |
| Returns a function that adjusts the static configuration file for testsuite. | |
| ServiceConfigPatch | pytest_userver.plugins.config.userver_config_deadlock_detector (str userver_deadlock_detector_mode) |
| Returns a function that adjusts the static configuration file for testsuite. | |
| str | pytest_userver.plugins.config.userver_deadlock_detector_mode () |
| Returns Deadlock detector mode for testsuite. | |
| pathlib.Path | pytest_userver.plugins.dumps.userver_dumps_root (tmp_path_factory) |
| The directory which the service will use for cache dumps. | |
| pytest_userver.plugins.dumps.read_latest_dump (userver_dumps_root) | |
| Read the latest dump produced by a specified dumper. | |
| pytest_userver.plugins.dumps.cleanup_userver_dumps (userver_dumps_root, request) | |
| To avoid leaking dumps between tests, cache_dump_dir must be cleaned after each test. | |
| dynconf.DynamicConfig | pytest_userver.plugins.dynamic_config.dynamic_config (request, search_path, object_substitute, cache_invalidation_state, _dynamic_config_defaults_storage, config_service_defaults, dynamic_config_changelog, _dynconf_load_json_cached, dynconf_cache_names) |
| Fixture that allows to control dynamic config values used by the service. | |
| dynconf.ConfigValuesDict | pytest_userver.plugins.dynamic_config.dynamic_config_fallback_patch () |
| Override this fixture to replace some dynamic config values specifically for testsuite tests: | |
| dynconf.ConfigValuesDict | pytest_userver.plugins.dynamic_config.config_service_defaults (config_fallback_path, dynamic_config_fallback_patch) |
| Fixture that returns default values for dynamic config. | |
| pytest_userver.plugins.dynamic_config.userver_config_dynconf_cache (service_tmpdir) | |
| Returns a function that adjusts the static configuration file for the testsuite. | |
| pytest_userver.plugins.dynamic_config.userver_config_dynconf_fallback (config_service_defaults) | |
| Returns a function that adjusts the static configuration file for the testsuite. | |
| pytest_userver.plugins.dynamic_config.userver_config_dynconf_url (mockserver_info) | |
| Returns a function that adjusts the static configuration file for the testsuite. | |
| None | pytest_userver.plugins.dynamic_config.mock_configs_service (mockserver, dynconf.DynamicConfig dynamic_config, dynconf._Changelog dynamic_config_changelog) |
| Adds a mockserver handler that forwards dynamic_config to service's dynamic-config-client component. | |
| int | pytest_userver.plugins.grpc.client.grpc_service_port_fallback () |
| Returns the gRPC port that should be used in service runner mode in case no port is specified in the source config_yaml. | |
| str | pytest_userver.plugins.grpc.client.grpc_service_endpoint (service_config) |
| Returns the gRPC endpoint of the service. | |
| float | pytest_userver.plugins.grpc.client.grpc_service_timeout (pytestconfig) |
| Returns the gRPC timeout for the service that is set by the command line option --service-timeout. | |
| pytest_userver.plugins.grpc.client.grpc_channel (service_client, grpc_service_endpoint, grpc_service_timeout, grpc_session_channel, request) | |
| Returns the gRPC channel configured by the parameters from the grpc_service_endpoint fixture. | |
| Generator[pathlib.Path, None, None] | pytest_userver.plugins.grpc.client.grpc_socket_path () |
| Path for the UNIX socket over which testsuite will talk to the gRPC service, if it chooses to use a UNIX socket. | |
| pytest_userver.plugins.grpc.client.userver_config_grpc_endpoint (pytestconfig, grpc_service_port_fallback, substitute_config_vars, request, choose_free_port) | |
| Returns a function that adjusts the static config for testsuite. | |
| str | pytest_userver.plugins.grpc.mockserver.grpc_mockserver_endpoint (pytestconfig, get_free_port) |
| Returns the gRPC endpoint to start the mocking server that is set by command line --grpc-mockserver-host and --grpc-mockserver-port options. | |
| AsyncIterator[pytest_userver.grpc.MockserverSession] | pytest_userver.plugins.grpc.mockserver.grpc_mockserver_session (grpc_mockserver_endpoint) |
| Returns the gRPC mocking server. | |
| Iterator[pytest_userver.grpc.Mockserver] | pytest_userver.plugins.grpc.mockserver.grpc_mockserver (grpc_mockserver_session, asyncexc_append) |
| Returns the gRPC mocking server. | |
| pytest_userver.plugins.grpc.mockserver.userver_config_grpc_mockserver () | |
| Returns a function that adjusts the static config for testsuite. | |
| list[str] | pytest_userver.plugins.kafka.kafka_components () |
| Should contain manually listed names of kafka producer and consumer components. | |
| dict | pytest_userver.plugins.kafka.kafka_secdist (_bootstrap_servers, kafka_components) |
| Automatically generates secdist config from user static config. | |
| logcapture.CaptureServer | pytest_userver.plugins.log_capture.userver_log_capture (pytestconfig, userver_log_level) |
| Session-scoped TCP server that receives service logs in TSKV format. | |
| pytest_userver.plugins.mongo.userver_mongo_config (mongo_connection_info) | |
| Returns a function that adjusts the static configuration file for the testsuite. | |
| pytest_userver.plugins.postgresql.userver_pg_config (pgsql_local) | |
| Returns a function that adjusts the static configuration file for the testsuite. | |
| sql.RegisteredTrx | pytest_userver.plugins.postgresql.userver_pg_trx (testpoint) |
| The fixture maintains transaction fault injection state using RegisteredTrx class. | |
| RegisteredNtrx | pytest_userver.plugins.postgresql.userver_pg_ntrx (testpoint) |
| The fixture maintains single query fault injection state using RegisteredNtrx class. | |
| pytest_userver.plugins.s3api._s3_mock_storage () | |
| In-memory S3 bucket storage for tests. | |
| ConnectionInfo | pytest_userver.plugins.scylla.scylla_connection_info (pytestconfig) |
| Where the ScyllaDB cluster is expected to be running. | |
| float | pytest_userver.plugins.scylla.scylla_wait_timeout (pytestconfig) |
| ConnectionInfo | pytest_userver.plugins.scylla.scylla (_scylla_tcp_ready, scylla_connection_info) |
| ScyllaDB connection info for the test. | |
| pytest_userver.plugins.scylla.userver_config_scylla (scylla_connection_info, _scylla_tcp_ready) | |
| dict[str, str] | pytest_userver.plugins.service.service_env () |
| Override this to pass extra environment variables to the service. | |
| str|None | pytest_userver.plugins.service.service_http_ping_url (service_config, service_baseurl) |
| Returns the service HTTP ping URL that is used by the testsuite to detect that the service is ready to work. | |
| net.HealthChecks | pytest_userver.plugins.service.service_non_http_health_checks (service_config) |
| Returns a health checks info. | |
| float | pytest_userver.plugins.service.service_start_timeout () |
| Returns service start timeout in seconds. | |
| pytest_userver.plugins.service.service_binary_launcher () | |
| If non-empty, defines a list of arguments starting with executable that is used instead of service_binary. | |
| Callable[..., Awaitable[bool]]|None | pytest_userver.plugins.service.service_health_check (service_http_ping_url, service_non_http_health_checks) |
| Returns the health check function used by service_daemon_scope to detect that the service has started and is ready to accept requests. | |
| pytest_userver.plugins.service.service_daemon_scope (create_daemon_scope, daemon_scoped_mark, service_env, service_http_ping_url, service_config_path_temp, service_binary, service_binary_launcher, service_health_check, service_start_timeout) | |
| Prepares the start of the service daemon. | |
| None | pytest_userver.plugins.service.extra_client_deps () |
| Service client dependencies hook. | |
| None | pytest_userver.plugins.service.auto_client_deps (request) |
| Ensures that the following fixtures, if available, are run before service start: | |
| pytest_userver.plugins.service.builtin_client_deps (testpoint, cleanup_userver_dumps, userver_log_capture, dynamic_config, mock_configs_service) | |
| Service client dependencies hook, like extra_client_deps. | |
| pytest_userver.plugins.service.service_daemon_instance (ensure_daemon_started, service_daemon_scope, builtin_client_deps, auto_client_deps, extra_client_deps) | |
| Calls ensure_daemon_started on service_daemon_scope to actually start the service. | |
| dict[str, Any]|None | pytest_userver.plugins.service.daemon_scoped_mark (request) |
| Depend on this fixture directly or transitively to make your fixture a per-daemon fixture. | |
| client.Client | pytest_userver.plugins.service_client.service_client (service_daemon_instance, service_baseurl, service_client_options, userver_service_client_options, userver_client_cleanup, client.TestsuiteClientConfig _testsuite_client_config) |
| Main fixture that provides access to userver based service. | |
| Callable[[client.Client], AsyncGenerator] | pytest_userver.plugins.service_client.userver_client_cleanup (request, service_logs_update_position, servicelogs_register_flusher, _dynamic_config_defaults_storage, _check_config_marks, dynamic_config) |
| Contains the pre-test and post-test setup that depends on service_client. | |
| pytest_userver.plugins.service_client.websocket_client (service_client, service_port) | |
| Fixture that provides access to userver based websocket service. | |
| client.ClientMonitor | pytest_userver.plugins.service_client.monitor_client (service_client, userver_monitor_client_options, monitor_baseurl) |
| Main fixture that provides access to userver monitor listener. | |
| str | pytest_userver.plugins.service_client.service_baseurl (service_port) |
| Returns the main listener URL of the service. | |
| str | pytest_userver.plugins.service_client.monitor_baseurl (monitor_port) |
| Returns the main monitor URL of the service. | |
| pytest_userver.plugins.sql_coverage.on_uncovered () | |
| Called when the coverage is incomplete. | |
| Coverage | pytest_userver.plugins.sql_coverage.sql_coverage (sql_files) |
| Returns data about the current coverage of statements. | |
| pytest_userver.plugins.sql_coverage.sql_statement_hook (testpoint, sql_coverage) | |
| Hook that accepts requests from the testpoint with information on PostgreSQL statements coverage. | |
| pytest_userver.plugins.sql_coverage.yql_statement_hook (testpoint, sql_coverage) | |
| Hook that accepts requests from the testpoint with information on YDB statements coverage. | |
| pytest_userver.plugins.sqlite.userver_sqlite_config (tmp_path_factory) | |
| Returns a function that adjusts the SQLite static configuration file for the testsuite. | |
| pytest_userver.plugins.sqlite.sqlite_db (_list_dbpath_components, service_client, testpoint) | |
| Removes all the data from SQLite tables at the end of the test to guarantee tests isolation. | |
| pytest_userver.plugins.testpoint.userver_config_testpoint (mockserver_info) | |
| Returns a function that adjusts the static configuration file for the testsuite. | |
| client.YdbClient | pytest_userver.plugins.ydb.ydbsupport.ydb (_ydb_client, _ydb_init) |
| YDB client fixture. | |
| pathlib.Path | pytest_userver.plugins.ydb.ydbsupport.ydb_migration_dir (service_source_dir) |
| Directory with migration files. | |
| pathlib.Path | pytest_userver.plugins.ydb.ydbsupport.goose_binary_path () |
| Path to 'goose' migration tool. | |
| pathlib.Path | pytest_userver.plugins.ydb.ydbsupport.ydb_cli () |
| Path to YDB CLI executable. | |
| sql.RegisteredTrx | pytest_userver.plugins.ydb.ydbsupport.userver_ydb_trx (testpoint) |
| The fixture maintains transaction fault injection state using RegisteredTrx class. | |
| pytest_userver.plugins.ydb.ydbsupport.userver_config_ydb (ydb_service_settings) | |
| Returns a function that adjusts the static configuration file for testsuite. | |
|
protected |
Factory for asyncio-compatible sockets used in TCP tests.
Definition at line 14 of file asyncio_socket.py.
|
protected |
| list[str] allowed_url_prefixes | ( | mockserver_info, | |
| mockserver_ssl_info, | |||
| allowed_url_prefixes_extra ) |
| list[str] allowed_url_prefixes_extra | ( | ) |
By default, userver HTTP client is only allowed to talk to mockserver when running in testsuite.
This makes tests repeatable and encapsulated.
Override this fixture to whitelist some additional URLs. It is still strongly advised to only talk to localhost in tests.
| asyncexc_append | ( | _asyncexc | ) |
Register background exception.
Part of the yandex-taxi-testsuite
Definition at line 33 of file asyncexc.py.
| asyncexc_check | ( | _asyncexc | ) |
Raise in case there are background exceptions.
Part of the yandex-taxi-testsuite
Definition at line 43 of file asyncexc.py.
| None auto_client_deps | ( | request | ) |
Ensures that the following fixtures, if available, are run before service start:
To add other dependencies prefer overriding the extra_client_deps fixture.
Definition at line 231 of file service.py.
| pathlib.Path build_dir | ( | pytestconfig | ) |
| builtin_client_deps | ( | testpoint, | |
| cleanup_userver_dumps, | |||
| userver_log_capture, | |||
| dynamic_config, | |||
| mock_configs_service ) |
Service client dependencies hook, like extra_client_deps.
Feel free to override globally in a more specific pytest plugin (one that comes after userver plugins), but make sure to depend on the original fixture:
Definition at line 289 of file service.py.
| InvalidationState cache_invalidation_state | ( | ) |
| Callable[[int | None], int] choose_free_port | ( | pytestconfig, | |
| get_free_port, | |||
| _testsuite_socket_cleanup, | |||
| _testsuite_default_af ) |
| cleanup_userver_dumps | ( | userver_dumps_root, | |
| request ) |
To avoid leaking dumps between tests, cache_dump_dir must be cleaned after each test.
To observe the dumps, add a final time.sleep(1000000) to your test locally. The returned function may also be used to clean dumps manually as appropriate.
| classes.DatabasesDict clickhouse_local | ( | ) |
Use to override databases configuration.
Part of the yandex-taxi-testsuite
Definition at line 143 of file pytest_plugin.py.
| pathlib.Path config_fallback_path | ( | pytestconfig | ) |
| dynconf.ConfigValuesDict config_service_defaults | ( | config_fallback_path, | |
| dynamic_config_fallback_patch ) |
Fixture that returns default values for dynamic config.
You may override it in your local conftest.py or fixture:
Definition at line 156 of file dynamic_config.py.
| bool congestion_control_fake_mode | ( | ) |
| CreateDaemonScope create_daemon_scope | ( | _DaemonStore | _global_daemon_store, |
| ServiceSpawnerFactory | service_spawner_factory ) |
Create daemon scope for daemon with command to start.
Part of the yandex-taxi-testsuite
Definition at line 342 of file pytest_plugin.py.
| dict[str, Any] | None daemon_scoped_mark | ( | request | ) |
Depend on this fixture directly or transitively to make your fixture a per-daemon fixture.
Example:
For tests marked with @pytest.mark.uservice_oneshot(...), the service will be restarted, and all the per-daemon fixtures will be recreated.
This fixture returns kwargs passed to the uservice_oneshot mark (which may be an empty dict). For normal tests, this fixture returns None.
Definition at line 340 of file service.py.
| pathlib.Path db_dump_schema_path | ( | service_binary, | |
| service_tmpdir ) |
| dynconf.DynamicConfig dynamic_config | ( | request, | |
| search_path, | |||
| object_substitute, | |||
| cache_invalidation_state, | |||
| _dynamic_config_defaults_storage, | |||
| config_service_defaults, | |||
| dynamic_config_changelog, | |||
| _dynconf_load_json_cached, | |||
| dynconf_cache_names ) |
Fixture that allows to control dynamic config values used by the service.
Example:
Example with kill switches:
HTTP and gRPC client requests call update_server_state automatically before each request.
For main dynamic config documentation:
See also other related fixtures:
Definition at line 27 of file dynamic_config.py.
| dynconf.ConfigValuesDict dynamic_config_fallback_patch | ( | ) |
Override this fixture to replace some dynamic config values specifically for testsuite tests:
Definition at line 139 of file dynamic_config.py.
| event_loop | ( | ) |
Overrides pytest-asyncio internal event_loop fixture.
Should not be used explicitly.
Required for compatibility with pytest-asyncio 0.21.x
Part of the yandex-taxi-testsuite
Definition at line 12 of file plugin_legacy.py.
| None extra_client_deps | ( | ) |
Service client dependencies hook.
Feel free to override, e.g.:
Definition at line 216 of file service.py.
| typing.Callable[[], int] get_free_port | ( | _get_free_port_sock_storing, | |
| _get_free_port_range_based ) |
Returns an ephemeral TCP port that is free for IPv4 and for IPv6.
Part of the yandex-taxi-testsuite
Definition at line 17 of file network.py.
| pathlib.Path goose_binary_path | ( | ) |
Path to 'goose' migration tool.
Override this fixture to change the way 'goose' binary is discovered.
Definition at line 178 of file ydbsupport.py.
| grpc_channel | ( | service_client, | |
| grpc_service_endpoint, | |||
| grpc_service_timeout, | |||
| grpc_session_channel, | |||
| request ) |
Returns the gRPC channel configured by the parameters from the grpc_service_endpoint fixture.
You can add interceptors to the channel by implementing the pytest_grpc_client_interceptors hook in your pytest plugin or initial (root) conftest.
| Iterator[pytest_userver.grpc.Mockserver] grpc_mockserver | ( | grpc_mockserver_session, | |
| asyncexc_append ) |
Returns the gRPC mocking server.
In order for gRPC clients in your service to work, mock handlers need to be installed for them using this fixture.
Example:
Alternatively, you can create a shorthand for mocking frequently-used services:
Mocks are only active within tests after their respective handler functions are created, not between tests. If the service needs the mock during startup, add the fixture that defines your mock to extra_client_deps.
To return an error status instead of response, use context (see ServicerContext docs):
To trigger special exceptions in the service's gRPC client, raise these mocked errors from the mock handler:
Definition at line 65 of file mockserver.py.
| str grpc_mockserver_endpoint | ( | pytestconfig, | |
| get_free_port ) |
Returns the gRPC endpoint to start the mocking server that is set by command line --grpc-mockserver-host and --grpc-mockserver-port options.
For port 0, picks some free port.
Override this fixture to customize the endpoint used by gRPC mockserver.
Definition at line 27 of file mockserver.py.
| AsyncIterator[pytest_userver.grpc.MockserverSession] grpc_mockserver_session | ( | grpc_mockserver_endpoint | ) |
Returns the gRPC mocking server.
Definition at line 48 of file mockserver.py.
| str grpc_service_endpoint | ( | service_config | ) |
Returns the gRPC endpoint of the service.
Used by grpc_channel fixture.
By default, gets the actual gRPC endpoint from service_config. Override this fixture if you add gRPC server listening ports in a custom way.
| int grpc_service_port_fallback | ( | ) |
| float grpc_service_timeout | ( | pytestconfig | ) |
| Generator[pathlib.Path, None, None] grpc_socket_path | ( | ) |
Path for the UNIX socket over which testsuite will talk to the gRPC service, if it chooses to use a UNIX socket.
| tuple[pathlib.Path, ...] initial_data_path | ( | ) |
Use this fixture to override base static search path.
Part of the yandex-taxi-testsuite
| list[str] kafka_components | ( | ) |
Should contain manually listed names of kafka producer and consumer components.
Definition at line 36 of file __init__.py.
| typing.AsyncGenerator[classes.KafkaConsumer, None] kafka_consumer | ( | _kafka_global_consumer | ) |
Per test Kafka consumer instance.
Part of the yandex-taxi-testsuite
Definition at line 77 of file pytest_plugin.py.
| dict[str, int] kafka_custom_topics | ( | ) |
Redefine this fixture to pass your custom dictionary of topics' settings.
Part of the yandex-taxi-testsuite
Definition at line 93 of file pytest_plugin.py.
| classes.BootstrapServers kafka_local | ( | ) |
Override to use custom local cluster bootstrap servers.
If not empty, no service started.
Part of the yandex-taxi-testsuite
Definition at line 105 of file pytest_plugin.py.
| typing.AsyncGenerator[classes.KafkaProducer, None] kafka_producer | ( | _kafka_global_producer | ) |
Per test Kafka producer instance.
Part of the yandex-taxi-testsuite
Definition at line 46 of file pytest_plugin.py.
| dict kafka_secdist | ( | _bootstrap_servers, | |
| kafka_components ) |
Automatically generates secdist config from user static config.
_bootstrap_servers is testsuite's fixture that determines current bootstrap servers list depends on Kafka testsuite plugin's settings.
Definition at line 48 of file __init__.py.
| LoadFixture load | ( | GetFilePathFixture | get_file_path | ) |
Returns a function that loads a static file as text.
Searches the file via get_file_path. Returns None when missing_ok=True and the file is absent.
Part of the yandex-taxi-testsuite
| LoadBinaryFixture load_binary | ( | GetFilePathFixture | get_file_path | ) |
Returns a function that loads a static file as bytes.
Searches the file via get_file_path.
Part of the yandex-taxi-testsuite
| LoadJsonFixture load_json | ( | LoadFixture | load, |
| JsonLoadsFixture | json_loads ) |
Returns a function that loads a static file as JSON.
Part of the yandex-taxi-testsuite
| LoadYamlFixture load_yaml | ( | LoadFixture | load | ) |
Returns a function that loads a static file as YAML.
Part of the yandex-taxi-testsuite
| None mock_configs_service | ( | mockserver, | |
| dynconf.DynamicConfig | dynamic_config, | ||
| dynconf._Changelog | dynamic_config_changelog ) |
Adds a mockserver handler that forwards dynamic_config to service's dynamic-config-client component.
Definition at line 316 of file dynamic_config.py.
| MockedTime mocked_time | ( | bool | _mocked_time_enabled, |
| datetime.datetime | now ) |
| types.YieldFixture[server.MockserverFixture] mockserver | ( | server.Server | _mockserver, |
| mockserver_create_session ) |
Returns per-test mockserver client.
Use it to register HTTP handlers that the service under test can call.
Part of the yandex-taxi-testsuite
Definition at line 191 of file pytest_plugin.py.
| classes.MockserverInfo mockserver_info | ( | classes.MockserverSocket | _mockserver_socket | ) |
Returns mockserver information object.
Part of the yandex-taxi-testsuite
Definition at line 221 of file pytest_plugin.py.
| tuple[str, ...] mongo_extra_connections | ( | ) |
Override this if you need to access mongo connections besides those defined in mongo_connections fixture.
Part of the yandex-taxi-testsuite
Definition at line 208 of file pytest_plugin.py.
| tuple[str, ...] mongo_schema_extra_directories | ( | ) |
Override to use collection schemas besides those defined by mongo_schema_directory fixture.
Part of the yandex-taxi-testsuite
Definition at line 252 of file pytest_plugin.py.
| CollectionWrapper mongodb | ( | mongodb_init, | |
| CollectionWrapper | _mongodb_local ) |
Returns MongoDB collections wrapper for the test.
Collections are initialized by the mongodb_init fixture.
Part of the yandex-taxi-testsuite
Definition at line 171 of file pytest_plugin.py.
| tuple[str, ...] mongodb_collections | ( | mongodb_settings | ) |
Override this to enable access to named collections within test module.
Returns all available collections by default.
Part of the yandex-taxi-testsuite
Definition at line 239 of file pytest_plugin.py.
| None mongodb_init | ( | request, | |
| verify_file_paths, | |||
| pathlib.Path | static_dir, | ||
| _mongodb_local, | |||
| _mongo_thread_pool, | |||
| _mongo_create_indexes, | |||
| _mongo_query_loader ) |
Populate mongodb with fixture data.
Part of the yandex-taxi-testsuite
Definition at line 332 of file pytest_plugin.py.
| str monitor_baseurl | ( | monitor_port | ) |
Returns the main monitor URL of the service.
Override this fixture to change the main monitor URL that the testsuite uses for tests.
Definition at line 243 of file service_client.py.
| client.ClientMonitor monitor_client | ( | service_client, | |
| userver_monitor_client_options, | |||
| monitor_baseurl ) |
Main fixture that provides access to userver monitor listener.
Definition at line 137 of file service_client.py.
| int monitor_port | ( | pytestconfig, | |
| _original_service_config, | |||
| choose_free_port ) |
Returns the monitor listener port number of the service set by command line --monitor-port option.
If no port is specified in the command line option, keeps the original port specified in the static config.
Override this fixture to change the way the monitor listener port number is detected by testsuite.
| dict[str, control.ConnectionWrapper] mysql | ( | _mysql, | |
| _mysql_apply ) |
MySQL fixture.
Returns dictionary where key is database alias and value is control.ConnectionWrapper
Part of the yandex-taxi-testsuite
Definition at line 30 of file pytest_plugin.py.
| classes.DatabasesDict mysql_local | ( | ) |
Use to override databases configuration.
Part of the yandex-taxi-testsuite
Definition at line 55 of file pytest_plugin.py.
| object_substitute | ( | object_hook | ) |
Perform object substitution as in load_json.
Part of the yandex-taxi-testsuite
| on_uncovered | ( | ) |
Called when the coverage is incomplete.
Override this fixture to change the way uncovered statements are reported or to ignore some of the statements from coverage report.
See SQL coverage tests for more info.
Definition at line 19 of file sql_coverage.py.
| dict[str, control.PgDatabaseWrapper] pgsql | ( | _pgsql, | |
| pgsql_apply ) |
Returns str to testsuite.databases.pgsql.control.PgDatabaseWrapper dictionary.
Example usage:
Part of the yandex-taxi-testsuite
Definition at line 123 of file pytest_plugin.py.
| None pgsql_apply | ( | ServiceLocalConfig | _pgsql, |
| load, | |||
| bool | pgsql_background_truncate_enabled, | ||
| bool | pgsql_parallelization_enabled, | ||
| _pgsql_apply_queries ) |
Initialize PostgreSQL database with data.
By default pg_${DBNAME}.sql and pg_${DBNAME}/*.sql files are used to fill PostgreSQL databases.
Use pytest.mark.pgsql to change this behaviour:
Part of the yandex-taxi-testsuite
Definition at line 319 of file pytest_plugin.py.
| ServiceLocalConfig pgsql_local | ( | pgsql_local_create | ) |
Configures local pgsql instance.
In order to use pgsql fixture you have to override pgsql_local() in your local conftest.py file, example:
Sometimes it is desirable to have tests-only database, maybe used in one particular test or tests group. This can be achieved by by overriding pgsql_local fixture in your test file:
pgsql_local provides access to PostgreSQL connection parameters:
Part of the yandex-taxi-testsuite
Definition at line 179 of file pytest_plugin.py.
| typing.Callable[ [list[discover.PgShardedDatabase]], ServiceLocalConfig, ] pgsql_local_create | ( | _pgsql_control, | |
| pgsql_cleanup_exclude_tables ) |
Creates pgsql configuration.
| databases | List of databases. |
Part of the yandex-taxi-testsuite
Definition at line 147 of file pytest_plugin.py.
| read_latest_dump | ( | userver_dumps_root | ) |
| redis_store | ( | pytestconfig, | |
| _redis_store, | |||
| _redis_execute_commands_from_file ) |
Returns a Redis client for the test store.
Commands from static files are applied before the test; the database is flushed afterwards.
Part of the yandex-taxi-testsuite
Definition at line 79 of file pytest_plugin.py.
| register_daemon_scope | ( | _DaemonStore | _global_daemon_store | ) |
Context manager that registers service process session.
Yields daemon scope instance.
| name | service name |
| spawn | asynccontextmanager service factory |
Part of the yandex-taxi-testsuite
Definition at line 494 of file pytest_plugin.py.
| ConnectionInfo scylla | ( | _scylla_tcp_ready, | |
| scylla_connection_info ) |
| ConnectionInfo scylla_connection_info | ( | pytestconfig | ) |
| str service_baseurl | ( | service_port | ) |
Returns the main listener URL of the service.
Override this fixture to change the main listener URL that the testsuite uses for tests.
Definition at line 230 of file service_client.py.
| pathlib.Path service_binary | ( | pytestconfig | ) |
| service_binary_launcher | ( | ) |
If non-empty, defines a list of arguments starting with executable that is used instead of service_binary.
The final argument list consists of service_binary_launcher plus the common service cmdline.
Can be used for:
Definition at line 113 of file service.py.
| client.Client service_client | ( | service_daemon_instance, | |
| service_baseurl, | |||
| service_client_options, | |||
| userver_service_client_options, | |||
| userver_client_cleanup, | |||
| client.TestsuiteClientConfig | _testsuite_client_config ) |
Main fixture that provides access to userver based service.
Definition at line 22 of file service_client.py.
| dict[str, str] service_client_default_headers | ( | ) |
Default service client headers.
Fill free to override in your conftest.py
Part of the yandex-taxi-testsuite
Definition at line 525 of file pytest_plugin.py.
| types.YieldFixture[dict[str, Any]] service_client_options | ( | pytestconfig, | |
| aiohttp.ClientSession | service_client_session, | ||
| fixture_types.MockserverFixture | mockserver ) |
Returns service client options dictionary.
Part of the yandex-taxi-testsuite
Definition at line 537 of file pytest_plugin.py.
| dict service_config | ( | service_config_yaml, | |
| service_config_vars, | |||
| substitute_config_vars ) |
| pathlib.Path service_config_path | ( | pytestconfig, | |
| service_binary ) |
| pathlib.Path service_config_path_temp | ( | service_tmpdir, | |
| service_config, | |||
| service_config_yaml, | |||
| service_config_vars ) |
| dict service_config_vars | ( | _service_config_hooked | ) |
Returns the static config variables (config_vars.yaml) values after the USERVER_CONFIG_HOOKS were applied (if any).
Prefer using pytest_userver.plugins.config.service_config
| pathlib.Path | None service_config_vars_path | ( | pytestconfig | ) |
| dict service_config_yaml | ( | _service_config_hooked | ) |
Returns the static config values after the USERVER_CONFIG_HOOKS were applied (if any).
Prefer using pytest_userver.plugins.config.service_config
| service_daemon_instance | ( | ensure_daemon_started, | |
| service_daemon_scope, | |||
| builtin_client_deps, | |||
| auto_client_deps, | |||
| extra_client_deps ) |
Calls ensure_daemon_started on service_daemon_scope to actually start the service.
Makes sure that all the dependencies are prepared before the service starts.
Definition at line 315 of file service.py.
| service_daemon_scope | ( | create_daemon_scope, | |
| daemon_scoped_mark, | |||
| service_env, | |||
| service_http_ping_url, | |||
| service_config_path_temp, | |||
| service_binary, | |||
| service_binary_launcher, | |||
| service_health_check, | |||
| service_start_timeout ) |
Prepares the start of the service daemon.
Configures the health checking via the service_health_check fixture.
Definition at line 184 of file service.py.
| dict[str, str] service_env | ( | ) |
Override this to pass extra environment variables to the service.
Definition at line 52 of file service.py.
| Callable[..., Awaitable[bool]] | None service_health_check | ( | service_http_ping_url, | |
| service_non_http_health_checks ) |
Returns the health check function used by service_daemon_scope to detect that the service has started and is ready to accept requests.
Returns None when service_http_ping_url is set, in which case create_daemon_scope uses the ping URL directly. Otherwise returns a checker based on the service_non_http_health_checks info.
Override this fixture to change the way the service readiness is detected.
Definition at line 132 of file service.py.
| str | None service_http_ping_url | ( | service_config, | |
| service_baseurl ) |
Returns the service HTTP ping URL that is used by the testsuite to detect that the service is ready to work.
Returns None if there's no such URL.
By default, attempts to find server.handlers.Ping component by "handler-ping" name in static config. Override this fixture to change the behavior.
Definition at line 63 of file service.py.
| net.HealthChecks service_non_http_health_checks | ( | service_config | ) |
Returns a health checks info.
By default, returns pytest_userver.utils.net.get_health_checks_info().
Override this fixture to change the way testsuite detects the tested service being alive.
Definition at line 82 of file service.py.
| int service_port | ( | pytestconfig, | |
| _original_service_config, | |||
| choose_free_port ) |
Returns the main listener port number of the service set by command line --service-port option.
If no port is specified in the command line option, keeps the original port specified in the static config.
Override this fixture to change the way the main listener port number is detected by the testsuite.
| pathlib.Path | None service_secdist_path | ( | pytestconfig | ) |
| pathlib.Path service_source_dir | ( | pytestconfig | ) |
| float service_start_timeout | ( | ) |
Returns service start timeout in seconds.
Override this fixture to change the service start timeout.
Definition at line 100 of file service.py.
| service_tmpdir | ( | service_binary, | |
| tmp_path_factory ) |
| Coverage sql_coverage | ( | sql_files | ) |
Returns data about the current coverage of statements.
See SQL coverage tests for more info.
Definition at line 61 of file sql_coverage.py.
| sql_statement_hook | ( | testpoint, | |
| sql_coverage ) |
Hook that accepts requests from the testpoint with information on PostgreSQL statements coverage.
See SQL coverage tests for more info.
Definition at line 73 of file sql_coverage.py.
| sqlite_db | ( | _list_dbpath_components, | |
| service_client, | |||
| testpoint ) |
| pathlib.Path static_dir | ( | testsuite_request_directory | ) |
Static directory related to test path.
Returns static directory relative to test file, e.g.
Part of the yandex-taxi-testsuite
| Callable[[Any, dict], Any] substitute_config_vars | ( | service_env | ) |
A function that takes config_yaml, config_vars and applies all substitutions just like the service would.
Useful when patching the service config. It's a good idea to pass a component's config instead of the whole config_yaml to avoid unnecessary work.
| TestpointFixture testpoint | ( | server.MockserverFixture | mockserver, |
| testpoint_checker_factory ) |
Testpoint fixture returns testpoint session instance that works as decorator that registers testpoint handler.
Original function is wrapped with testsuite.utils.callinfo.AsyncCallQueue.
| name | testpoint name |
Part of the yandex-taxi-testsuite
Definition at line 98 of file testpoint.py.
| testpoint_checker_factory | ( | ) |
Testpoint checker factory fixture.
Can be used to control whether or not testpoint is valid. Feel free to override, e.g.:
Part of the yandex-taxi-testsuite
Definition at line 68 of file testpoint.py.
| str testsuite_trace_id | ( | testsuite_traceid_generator, | |
| _testsuite_traceid_history ) |
| testsuite_traceid_generator | ( | ) |
Fill free to override this fixture with our own.
Part of the yandex-taxi-testsuite
Definition at line 9 of file tracing.py.
| TraceidManager testsuite_traceid_manager | ( | str | testsuite_trace_id, |
| _testsuite_traceid_history ) |
TraceidManager associated with current testcase.
Part of the yandex-taxi-testsuite
Definition at line 39 of file tracing.py.
| CacheControl userver_cache_control | ( | _userver_cache_control_context, | |
| _userver_cache_fixtures, | |||
| request ) |
Userver cache control handler.
To install per cache handler use USERVER_CACHE_CONTROL_HOOKS variable in your pytest plugin:
| Callable[[client.Client], AsyncGenerator] userver_client_cleanup | ( | request, | |
| service_logs_update_position, | |||
| servicelogs_register_flusher, | |||
| _dynamic_config_defaults_storage, | |||
| _check_config_marks, | |||
| dynamic_config ) |
Contains the pre-test and post-test setup that depends on service_client.
Feel free to override, but in that case make sure to call the original userver_client_cleanup fixture instance.
Definition at line 51 of file service_client.py.
| ServiceConfigPatch userver_config_deadlock_detector | ( | str | userver_deadlock_detector_mode | ) |
Returns a function that adjusts the static configuration file for testsuite.
Sets the deadlock_detector parameter of the coro_pool component to the value of userver_deadlock_detector_mode fixture.
| userver_config_dynconf_cache | ( | service_tmpdir | ) |
Returns a function that adjusts the static configuration file for the testsuite.
Sets dynamic-config.fs-cache-path to a file that is reset after the tests to avoid leaking dynamic config values between test sessions.
Definition at line 216 of file dynamic_config.py.
| userver_config_dynconf_fallback | ( | config_service_defaults | ) |
Returns a function that adjusts the static configuration file for the testsuite.
Removes dynamic-config.defaults-path. Updates dynamic-config.defaults with config_service_defaults.
Definition at line 244 of file dynamic_config.py.
| userver_config_dynconf_url | ( | mockserver_info | ) |
Returns a function that adjusts the static configuration file for the testsuite.
Sets the dynamic-config-client.config-url to the value of mockserver configs-service, so that the mock_configs_service fixture could work.
Definition at line 280 of file dynamic_config.py.
| userver_config_grpc_endpoint | ( | pytestconfig, | |
| grpc_service_port_fallback, | |||
| substitute_config_vars, | |||
| request, | |||
| choose_free_port ) |
Returns a function that adjusts the static config for testsuite.
Override this fixture to change the way grpc-server endpoint config is patched for tests.
| userver_config_grpc_mockserver | ( | ) |
Returns a function that adjusts the static config for testsuite.
Finds grpc-client-middleware-pipeline in config_yaml and enables grpc-client-middleware-testsuite.
Definition at line 107 of file mockserver.py.
| ServiceConfigPatch userver_config_http_client | ( | allowed_url_prefixes | ) |
| ServiceConfigPatch userver_config_http_server | ( | service_port, | |
| monitor_port ) |
Returns a function that adjusts the static configuration file for testsuite.
Sets the server.listener.port to listen on service_port fixture value; sets the server.listener-monitor.port to listen on monitor_port fixture value.
| ServiceConfigPatch userver_config_logging | ( | userver_log_level, | |
| _service_logfile_path ) |
| ServiceConfigPatch userver_config_logging_otlp | ( | ) |
| userver_config_scylla | ( | scylla_connection_info, | |
| _scylla_tcp_ready ) |
| ServiceConfigPatch userver_config_secdist | ( | service_secdist_path | ) |
Returns a function that adjusts the static configuration file for testsuite.
Sets the default-secdist-provider.config to the value of service_secdist_path fixture.
| ServiceConfigPatch userver_config_substitutions | ( | _service_config_substitution_vars | ) |
Replaces substitution vars in all strings within config_vars using string.Template.substitute.
Substitution vars can be used as a shorthand for writing a full-fledged config hook in many common cases.
Unlike normal config_vars, substitution vars can also apply to a part of a string. For example, for config_vars entry
a possible patching result is as follows:
Currently, the following substitution vars are supported:
| userver_config_testpoint | ( | mockserver_info | ) |
Returns a function that adjusts the static configuration file for the testsuite.
Sets the tests-control.skip-unregistered-testpoints to True.
Definition at line 51 of file testpoint.py.
| ServiceConfigPatch userver_config_testsuite | ( | pytestconfig, | |
| mockserver_info ) |
Returns a function that adjusts the static configuration file for testsuite.
Sets up testsuite-support component, which:
Sets the testsuite-enabled in config_vars.yaml to True; sets the tests-control.testpoint-url to mockserver URL.
| userver_config_ydb | ( | ydb_service_settings | ) |
Returns a function that adjusts the static configuration file for testsuite.
For all ydb.databases, sets endpoint and database to the local test YDB instance.
Definition at line 342 of file ydbsupport.py.
| str userver_deadlock_detector_mode | ( | ) |
Returns Deadlock detector mode for testsuite.
Override this fixture to modify the deadlock detector settings. By default, it operates in detect-only mode. For a full list of available options, refer to the coro_pool.deadlock_detector parameter in the components.ManagerControllerComponent.
| str userver_default_log_level | ( | ) |
| pathlib.Path userver_dumps_root | ( | tmp_path_factory | ) |
The directory which the service will use for cache dumps.
Dumps of individual components will be stored in {userver_dumps_root}/{component-name}/{datetime}-v{format-version}
| logcapture.CaptureServer userver_log_capture | ( | pytestconfig, | |
| userver_log_level ) |
Session-scoped TCP server that receives service logs in TSKV format.
The server is started once per testsuite session. Static config is patched so that the service can send logs when log capture is enabled for a test.
In most tests use service_client.capture_logs() instead of this fixture directly. See testsuite_logs_capture.
Example — filter captured logs after a request:
Example — subscribe to log events as they arrive:
Definition at line 37 of file log_capture.py.
| str userver_log_level | ( | pytestconfig, | |
| userver_default_log_level ) |
Returns –service-log-level value if provided, otherwise returns userver_default_log_level() value from fixture.
| userver_mongo_config | ( | mongo_connection_info | ) |
| userver_pg_config | ( | pgsql_local | ) |
Returns a function that adjusts the static configuration file for the testsuite.
Sets the dbconnection to the testsuite started PostgreSQL credentials if there's only one dbconnection in static config.
Definition at line 72 of file postgresql.py.
| RegisteredNtrx userver_pg_ntrx | ( | testpoint | ) |
The fixture maintains single query fault injection state using RegisteredNtrx class.
Definition at line 148 of file postgresql.py.
| sql.RegisteredTrx userver_pg_trx | ( | testpoint | ) |
The fixture maintains transaction fault injection state using RegisteredTrx class.
Definition at line 125 of file postgresql.py.
| userver_sqlite_config | ( | tmp_path_factory | ) |
| sql.RegisteredTrx userver_ydb_trx | ( | testpoint | ) |
The fixture maintains transaction fault injection state using RegisteredTrx class.
Definition at line 319 of file ydbsupport.py.
| websocket_client | ( | service_client, | |
| service_port ) |
Fixture that provides access to userver based websocket service.
Usage example:
You can pass extra kwargs to get, they will be forwarded to websockets.connect.
Definition at line 103 of file service_client.py.
| client.YdbClient ydb | ( | _ydb_client, | |
| _ydb_init ) |
YDB client fixture.
Definition at line 28 of file ydbsupport.py.
| pathlib.Path ydb_cli | ( | ) |
Path to YDB CLI executable.
Override this fixture to change the way YDB CLI is discovered.
Definition at line 230 of file ydbsupport.py.
| pathlib.Path ydb_migration_dir | ( | service_source_dir | ) |
Directory with migration files.
Definition at line 140 of file ydbsupport.py.
| yql_statement_hook | ( | testpoint, | |
| sql_coverage ) |
Hook that accepts requests from the testpoint with information on YDB statements coverage.
See SQL coverage tests for more info.
Definition at line 90 of file sql_coverage.py.