userver: pytest_userver.plugins.config Namespace Reference
Loading...
Searching...
No Matches
pytest_userver.plugins.config Namespace Reference

Detailed Description

Work with the configuration files of the service in testsuite.

Functions

pathlib.Path service_config_path (pytestconfig)
 Returns the path to service.yaml file set by command line --service-config option.
 
typing.Optional[pathlib.Path] service_config_vars_path (pytestconfig)
 Returns the path to config_vars.yaml file set by command line --service-config-vars option.
 
typing.Optional[pathlib.Path] service_secdist_path (pytestconfig)
 Returns the path to secure_data.json file set by command line --service-secdist option.
 
pathlib.Path config_fallback_path (pytestconfig)
 Returns the path to dynamic config fallback file set by command line --config-fallback option.
 
 service_tmpdir (service_binary, tmp_path_factory)
 Returns the path for temporary files.
 
pathlib.Path service_config_path_temp (service_tmpdir, service_config, service_config_yaml)
 Dumps the contents of the service_config_yaml into a static config for testsuite and returns the path to the config file.
 
dict service_config_yaml (_service_config_hooked)
 Returns the static config values after the USERVER_CONFIG_HOOKS were applied (if any).
 
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).
 
None _substitute_values (config, dict service_config_vars, service_env)
 
dict service_config (service_config_yaml, service_config_vars, service_env)
 Returns the static config values after the USERVER_CONFIG_HOOKS were applied (if any) and with all the '$', environment and fallback variables substituted.
 
_UserverConfig _original_service_config (service_config_path, service_config_vars_path)
 
_UserverConfig _service_config_hooked (pytestconfig, request, service_tmpdir, _original_service_config)
 
 userver_config_http_server (service_port, monitor_port)
 Returns a function that adjusts the static configuration file for testsuite.
 
typing.List[str] allowed_url_prefixes_extra ()
 By default, userver HTTP client is only allowed to talk to mockserver when running in testsuite.
 
 userver_config_http_client (mockserver_info, mockserver_ssl_info, allowed_url_prefixes_extra)
 Returns a function that adjusts the static configuration file for testsuite.
 
str userver_default_log_level ()
 Default log level to use in userver if no caoomand line option was provided.
 
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_config_logging (userver_log_level, _service_logfile_path)
 Returns a function that adjusts the static configuration file for testsuite.
 
 userver_config_testsuite (pytestconfig, mockserver_info)
 Returns a function that adjusts the static configuration file for testsuite.
 
 userver_config_secdist (service_secdist_path)
 Returns a function that adjusts the static configuration file for testsuite.
 
 userver_config_testsuite_middleware (bool userver_testsuite_middleware_enabled)
 
bool userver_testsuite_middleware_enabled ()
 Enabled testsuite middleware.
 

Variables

list USERVER_CONFIG_HOOKS
 Fixtures and functions in USERVER_CONFIG_HOOKS used to change the static config or config_vars.yaml.
 

Function Documentation

◆ _original_service_config()

_UserverConfig pytest_userver.plugins.config._original_service_config ( service_config_path,
service_config_vars_path )
protected

Definition at line 283 of file config.py.

◆ _service_config_hooked()

_UserverConfig pytest_userver.plugins.config._service_config_hooked ( pytestconfig,
request,
service_tmpdir,
_original_service_config )
protected

Definition at line 302 of file config.py.

◆ _substitute_values()

None pytest_userver.plugins.config._substitute_values ( config,
dict service_config_vars,
service_env )
protected

Definition at line 222 of file config.py.

◆ userver_config_testsuite_middleware()

pytest_userver.plugins.config.userver_config_testsuite_middleware ( bool userver_testsuite_middleware_enabled)

Definition at line 548 of file config.py.

◆ userver_testsuite_middleware_enabled()

bool pytest_userver.plugins.config.userver_testsuite_middleware_enabled ( )

Enabled testsuite middleware.

Definition at line 569 of file config.py.

Variable Documentation

◆ USERVER_CONFIG_HOOKS

list pytest_userver.plugins.config.USERVER_CONFIG_HOOKS

Fixtures and functions in USERVER_CONFIG_HOOKS used to change the static config or config_vars.yaml.

Functions and fixtures that are listed in the USERVER_CONFIG_HOOKS variable in your pytest-plugin are run before config is written to disk, so that the service, the pytest_userver.plugins.config.service_config_yaml and the pytest_userver.plugins.config.service_config_vars get the modified values.

Example of patching config :

USERVER_CONFIG_HOOKS = ['prepare_service_config']
@pytest.fixture(scope='session')
def prepare_service_config(grpc_mockserver_endpoint):
def patch_config(config, config_vars):
components = config['components_manager']['components']
components['greeter-client']['endpoint'] = grpc_mockserver_endpoint
return patch_config

Definition at line 32 of file config.py.