glare.tests package

Subpackages

Submodules

glare.tests.hooks_artifact module

class glare.tests.hooks_artifact.HookChecker(context=None, **kwargs)[source]

Bases: glare.objects.base.BaseArtifact

artifact_type_opts = [<oslo_config.cfg.StrOpt object at 0x6eb6990>]
fields = {‘temp_file_path_activate’: String(default=None,nullable=True), ‘temp_file_path_reactivate’: String(default=None,nullable=True), ‘blob’: BlobFieldType(default=None,nullable=True), ‘temp_dir’: String(default=None,nullable=True), ‘temp_file_path_update’: String(default=None,nullable=True), ‘temp_file_path_publish’: String(default=None,nullable=True), ‘temp_file_path_create’: String(default=None,nullable=True), ‘temp_file_path_deactivate’: String(default=None,nullable=True)}
classmethod get_type_name()[source]
classmethod post_activate_hook(context, af)[source]
classmethod post_add_location_hook(context, af, field_name, blob_key)[source]
classmethod post_create_hook(context, af)[source]
classmethod post_deactivate_hook(context, af)[source]
classmethod post_delete_hook(context, af)[source]
classmethod post_download_hook(context, af, field_name, blob_key, fd)[source]
classmethod post_publish_hook(context, af)[source]
classmethod post_reactivate_hook(context, af)[source]
classmethod post_update_hook(context, af)[source]
classmethod post_upload_hook(context, af, field_name, blob_key)[source]
classmethod pre_activate_hook(context, af)[source]
classmethod pre_add_location_hook(context, af, field_name, blob_key, location)[source]
classmethod pre_create_hook(context, af)[source]
classmethod pre_deactivate_hook(context, af)[source]
classmethod pre_delete_hook(context, af)[source]
classmethod pre_download_hook(context, af, field_name, blob_key)[source]
classmethod pre_publish_hook(context, af)[source]
classmethod pre_reactivate_hook(context, af)[source]
classmethod pre_update_hook(context, af)[source]
classmethod pre_upload_hook(context, af, field_name, blob_key, fd)[source]

glare.tests.sample_artifact module

Sample artifact object for testing purposes

class glare.tests.sample_artifact.SampleArtifact(context=None, **kwargs)[source]

Bases: glare.objects.base.BaseArtifact

VERSION = ‘1.0’
fields = {‘dict_of_int’: Dict(default={},nullable=True), ‘list_of_str’: List(default=[],nullable=True), ‘list_of_int’: List(default=[],nullable=True), ‘float1’: Float(default=None,nullable=True), ‘float2’: Float(default=None,nullable=True), ‘dict_of_links’: Dict(default={},nullable=True), ‘bool1’: FlexibleBoolean(default=False,nullable=True), ‘bool2’: FlexibleBoolean(default=False,nullable=True), ‘str1’: String(default=None,nullable=True), ‘blob’: BlobFieldType(default=None,nullable=True), ‘dict_of_blobs’: Dict(default={},nullable=True), ‘dict_validators’: Dict(default=None,nullable=True), ‘link1’: LinkFieldType(default=None,nullable=True), ‘string_required’: String(default=None,nullable=True), ‘link2’: LinkFieldType(default=None,nullable=True), ‘list_validators’: List(default=[],nullable=True), ‘string_regex’: String(default=None,nullable=True), ‘int1’: Integer(default=None,nullable=True), ‘int2’: Integer(default=None,nullable=True), ‘string_validators’: String(default=None,nullable=True), ‘dict_of_str’: Dict(default={},nullable=True), ‘list_of_links’: List(default=[],nullable=True), ‘int_validators’: Integer(default=None,nullable=True), ‘system_attribute’: String(default=default,nullable=True), ‘small_blob’: BlobFieldType(default=None,nullable=True), ‘string_mutable’: String(default=None,nullable=True)}
classmethod get_type_name()[source]

glare.tests.unpacking_artifact module

class glare.tests.unpacking_artifact.Unpacker(context=None, **kwargs)[source]

Bases: glare.objects.base.BaseArtifact

MAX_BLOB_SIZE = 100000
fields = {‘content’: Dict(default={},nullable=True), ‘zip’: BlobFieldType(default=None,nullable=True)}
classmethod get_type_name()[source]
classmethod pre_upload_hook(context, af, field_name, blob_key, fd)[source]

glare.tests.utils module

Common utilities used in testing

class glare.tests.utils.BaseTestCase(*args, **kwargs)[source]

Bases: testtools.testcase.TestCase

config(**kw)[source]

Override some configuration values.

The keyword arguments are the names of configuration options to override and their values. If a group argument is supplied, the overrides are applied to the specified configuration option group. All overrides are automatically cleared at the end of the current test by the fixtures cleanup process.

setUp()[source]
set_policy()[source]
class glare.tests.utils.depends_on_exe(exe)[source]

Bases: object

Decorator to skip test if an executable is unavailable

glare.tests.utils.execute(cmd, raise_error=True, no_venv=False, exec_env=None, expect_exit=True, expected_exitcode=0, context=None)[source]

Executes a command in a subprocess.

Returns a tuple of (exitcode, out, err), where out is the string output from stdout and err is the string output from stderr when executing the command.

Parameters:
  • cmd – Command string to execute
  • raise_error – If returncode is not 0 (success), then raise a RuntimeError? Default: True)
  • no_venv – Disable the virtual environment
  • exec_env – Optional dictionary of additional environment variables; values may be callables, which will be passed the current value of the named environment variable
  • expect_exit – Optional flag true iff timely exit is expected
  • expected_exitcode – expected exitcode from the launcher
  • context – additional context for error message
glare.tests.utils.find_executable(cmdname)[source]

Searches the path for a given cmdname.

Returns an absolute filename if an executable with the given name exists in the path, or None if one does not.

Parameters:cmdname – The bare name of the executable to search for
glare.tests.utils.fork_exec(cmd, exec_env=None, logfile=None, pass_fds=None)[source]

Execute a command using fork/exec.

This is needed for programs system executions that need path searching but cannot have a shell as their parent process, for example: glare. When glare starts it sets itself as the parent process for its own process group. Thus the pid that a Popen process would have is not the right pid to use for killing the process group. This patch gives the test env direct access to the actual pid.

Parameters:
  • cmd – Command to execute as an array of arguments.
  • exec_env – A dictionary representing the environment with which to run the command.
  • logfile – A path to a file which will hold the stdout/err of the child process.
  • pass_fds – Sequence of file descriptors passed to the child.
glare.tests.utils.get_unused_port()[source]

Returns an unused port on localhost.

glare.tests.utils.get_unused_port_and_socket()[source]

Returns an unused port on localhost and the open socket from which it was created.

class glare.tests.utils.requires(setup=None, teardown=None)[source]

Bases: object

Decorator that initiates additional test setup/teardown.

glare.tests.utils.safe_mkdirs(path)[source]
glare.tests.utils.skip_if_disabled(func)[source]

Decorator that skips a test if test case is disabled.

glare.tests.utils.wait_for_fork(pid, raise_error=True, expected_exitcode=0)[source]

Wait for a process to complete

This function will wait for the given pid to complete. If the exit code does not match that of the expected_exitcode an error is raised.

glare.tests.utils.xattr_writes_supported(path)[source]

Returns True if the we can write a file to the supplied path and subsequently write a xattr to that file.

Module contents