CliCmdTestBase¶
- 
class lsst.daf.butler.tests.CliCmdTestBase¶
- Bases: - abc.ABC- A test case base that is used to verify click command functions import and call their respective script functions correctly. - Attributes Summary - cli- Get the command line interface function under test, can be overridden to test CLIs other than butler. - mock- Get the mock object to use in place of - mockFuncName.- mockFuncName- The qualified name of the function to mock, will be passed to unittest.mock.patch, see python docs for details. - Methods Summary - command()- Get the click.Command being tested. - defaultExpected()- makeExpected(**kwargs)- run_command(inputs)- Use the LogCliRunner with the mock environment variable set to execute a butler subcommand and parameters specified in inputs. - run_missing(inputs, expectedMsg)- Run the subcommand specified in inputs and verify a failed outcome where exit code != 0 and an expected message has been written to stdout. - run_test(inputs, expectedKwargs, str], …)- Run the subcommand specified in inputs and verify a successful outcome where exit code = 0 and the mock object has been called with the expected arguments. - setUp()- test_help()- Attributes Documentation - 
cli¶
- Get the command line interface function under test, can be overridden to test CLIs other than butler. 
 - 
mock¶
- Get the mock object to use in place of - mockFuncName. If not provided will use the default provided by- unittest.mock.patch, this is usually a- unittest.mock.MagicMock.
 - 
mockFuncName¶
- The qualified name of the function to mock, will be passed to unittest.mock.patch, see python docs for details. 
 - Methods Documentation - 
static command() → click.Command¶
- Get the click.Command being tested. 
 - 
static defaultExpected() → dict¶
 - 
classmethod makeExpected(**kwargs) → dict¶
 - 
run_command(inputs: list[str]) → click.testing.Result¶
- Use the LogCliRunner with the mock environment variable set to execute a butler subcommand and parameters specified in inputs. - Parameters: - inputs : [str]
- A list of strings that begins with the subcommand name and is followed by arguments, option keys and option values. 
 - Returns: - result : click.testing.Result
- The Result object contains the results from calling self.runner.invoke. 
 
- inputs : [
 - 
run_missing(inputs: list, expectedMsg: str) → None¶
- Run the subcommand specified in inputs and verify a failed outcome where exit code != 0 and an expected message has been written to stdout. - Parameters: 
 - 
run_test(inputs: list[str], expectedKwargs: dict[str, str], withTempFile: str | None = None) → click.testing.Result¶
- Run the subcommand specified in inputs and verify a successful outcome where exit code = 0 and the mock object has been called with the expected arguments. - Returns the result object for inspection, e.g. sometimes it’s useful to be able to inspect or print - result.output.- Parameters: - inputs : [str]
- A list of strings that begins with the subcommand name and is followed by arguments, option keys and option values. 
- expectedKwargs : dict[str,str]
- The arguments that the subcommand function is expected to have been called with. Keys are the argument name and values are the argument value. 
- withTempFile : str, optional
- If not None, will run in a temporary directory and create a file with the given name, can be used with commands with parameters that require a file to exist. 
 - Returns: - result : click.testing.Result
- The result object produced by invocation of the command under test. 
 
- inputs : [
 - 
setUp() → None¶
 - 
test_help() → None¶
 
-