This package implements the htsql-ctl script.
Implements the htsql-ctl script.
Usage:
ctl = HTSQL_CTL(stdin, stdout, stderr)
exit_code = ctl.main(argv)
This module implements the default routine.
Implements the default routine.
The default routine is executed when no explicit routine name is given.
This module implements exceptions raised by command-line scripts.
A fatal application error.
This module implements the extension routine.
This module implements the help routine.
Implements the help routine.
When called without any parameters, it describes the application. When called with a routine name, it describes the routine.
This module defines script options.
Describes a script option.
When an option does not require a parameter, the value of the option is either False or True. If the option is provided in the command line, the value is True; otherwise, the value is False.
When an option requires a parameter, the value of the option is determined by the parameter and the attributes validator and default. If the option is not provided, its value is equal to default. If the option is provided, its value is the value of the option parameter normalized by application of validator.
Returns a short one-line description of the option.
Returns the signature of the option parameters.
This module implements the regress routine.
A readable file-like object with an “echo”. Whenever some content is read from it, the same content is echoed to the specified output stream.
Use TermStringIO to preserve the content of interactive sessions with pre-recorded input. Assign:
sys.stdout = StringIO.StringIO()
sys.stdin = TermStringIO(input, sys.stdout)
where input contains the pre-recorded input data. After the session is done, the content of sys.stdout will be the same as if the session was performed on a real terminal with echo enabled.
Describes a parameter of test data.
Returns short one-line description of the field.
Returns the field name.
Indicates that test data may contain extra fields.
Add AnyField() to the fields list to indicate that YAML representation of test data may contain some attributes not described by other fields. These extra attributes will be silently ignored.
Represents input or output data of a test case.
This is an abstract class. Create a subclass of TestData to describe input or output data for a specific test kind. You need to specify the format of test data using the fields class attribute.
The fields attribute is a list of Field instances. Each field describes an attribute of test data.
Instances if TestData are YAML-serializable. A instance of a TestData subclass is represented as a mapping YAML node. The sets of keys and the format of the values come from the fields list. Add an AnyField instance to fields to indicate that the mapping node may contain some extra fields (which are to be ignored).
The constructor of TestData accepts the following arguments:
Normalize field values.
Describes a test type.
This an abstract class. Create a subclass of TestCase to describe a new type of test case. When subclassing, define the following class attributes:
You also need to override methods verify() and train() to specify how to execute the test case in a normal and in a train mode.
The constructor of TestCase takes the following arguments:
Returns short one-line description of the test case.
Returns long description of the test case.
Checks if the given input and output records belong to the same test case.
Note that we assume that both test input and test output have a field with the same attribute name. This attribute is called the key attribute. Input data matches output data when the values of their key attribute are equal.
For container test cases, returns a set of test suites that belong to the test case; otherwise returns an empty set.
Print values to the standard output stream.
out() supports the same options as htsql.ctl.script.Script.out() and an extra option:
Asks the user a question; returns the reply.
Typically the question has the form:
Press ENTER to perform <the default action>,
'x'+ENTER to perform <another action>,
'y'+ENTER to perform <another action>,
'z'+ENTER to perform <another action>.
In this case, choices should be equal to:
['', 'x', 'y', 'z']
The reply is stripped of leading and trailing whitespaces and translated to the lower case.
Ask if the user wants to halt the tests.
Returns DO_HALT or DO_CONTINUE.
Ask if the user wants to remember the new output of a test case.
Returns DO_RECORD, DO_SKIP, or DO_HALT.
Ask if the user wants to save the updated output data.
Returns DO_SAVE or DO_DISCARD.
Prints an exception traceback.
Prints a separator: a long line of dashes.
Prints a nice header describing the test case.
Indicate that the test case failed and stop the tests.
Indicate that the test case failed; stop the tests unless --force or --train flags are set.
Indicate that the output of the test case has been updated.
Indicate that the test case passed.
Executes the test case.
This method runs the test case with the given input data. If the test completed without errors, compare the produced output with the given expected output.
The test case fails if
Some test cases may not generate output; in this case the test passes if it is completed without errors.
Executes the test case in the training mode; returns the output data.
In the train mode, when the expected test output is not equal to the actual test output, the user is given a choice to update the expected test output.
Note that when the output has not been changed or the user refused to update it, the method must return the original output data, self.output.
Implements a skippable test case.
This is an abstract mixin class; subclasses should call skipped() to check if the test case is enabled or not.
Checks if the test is disabled.
Activates a named toggle.
Implements common methods for a broad category of test cases.
This class implements common scenario: run the test, get the output and compare it with the expected output.
This is an abstract class; create a subclass to implement a concrete test case. The following methods has to be overridden: execute(), render() and differs().
Prints the lines with the specified identation.
Prints the delta between two test outputs.
Converts the output data to a list of lines.
Runs the test case; returns the produced output.
Returns None if an error occured when running the test case.
Checks if the actual test output differs from the expected test output.
Configures the HTSQL application.
Loads an existing configuration of an HTSQL application.
Loads input test data from a file.
Implements a container of test cases.
Performs an HTSQL query.
Executes a script routine.
Keeps information on the started processes.
Class attributes:
Attributes:
Starts a new process.
Returns a new Fork instance.
Ends the process.
Returns the content of the standard output.
Starts a long-running routine.
Terminates a long-running routine.
Executes arbitrary Python code.
Executes arbitrary Python code loaded from a file.
Executes a SQL query.
Returns the SQL data to execute.
Loads SQL queries from a file and executes them.
Writes some data to a file.
Reads the file content.
Removes the specified files.
Creates a directory.
Removes a directory.
Keeps the mutable state of the testing process.
Loads test data from a YAML file.
Loads test data from the YAML stream.
Dumps test data to a YAML file.
Dumps the data to the YAML stream.
This module implements the get and post routines.
Represents a WSGI request.
Produces a Request object from the given parameters.
Represents a response to a WSGI request.
Updates the response parameters.
Returns True if the response is complete; False otherwise.
The response is considered valid if the HTTP status, headers and body are set and valid and no exception occured during the execution of the request.
Writes the response to the output stream.
Implements the common methods for the get and post routines.
Both routines take a connection URI and an HTSQL query as arguments and execute an HTTP request.
Implements the get routine.
The routine executes an HTSQL query over the specified database.
Implements the post routine.
The routine executes an HTSQL query with POST data over the specified database.
This module defines basic classes for implementing script routines.
Describes an argument of a script routine.
Returns a short one-line description of the argument.
Returns the argument signature.
Describes a script routine.
Routine is a base abstract class for implementing a script routine. To create a concrete routine, subclass Routine, declare the routine name, arguments and options, and override run().
The following class attributes should be overridden.
The constructor of Routine accepts the following arguments:
Returns a short one-line description of the routine.
Returns a long description of the routine.
Returns the routine signature.
Finds some routine feature by name.
Executes the routine. Returns an exit code.
This module implements a command-line application with subcommands.
Implements a command-line application with the following interface:
ctl <routine> <options> <arguments>
A list of routine options. The set of supported options is routine-specific.
Each option may be written using either an abbreviated form (a dash + a character) or a full form (two dashes + the option name). For instance, the quiet option may be written as -q or as --quiet.
Some options expect a parameter, which should then follow the option name. For instance, the input option expects a file name parameter, which could be passed using one of the following forms:
Two or more options written using an abbreviated form could share the leading dash. For instance, -q -iFILE could also be written as -qiFILE. When this form is used, only the last option in the list could accept a parameter.
Note that the order and the position of options in the command line is not fixed. In particular, an option could preceed the routine name or follow a routine argument. Use special parameter -- to indicate that there are no more options in the list of the remaining parameters. This is useful when a routine argument starts with a dash.
Script is the base abstract class implementing a command-line application with subcommands. To create a concrete application, do the following:
The constructor of Script accepts the following arguments:
Execute the application.
Returns an exit status suitable for passing to sys.exit(). The exit status could be None, an integer value, or an exception object. Note that when a non-integer value is passed to sys.exit(), the value is printed and the system exit code is set to one.
Print the values to the standard output stream.
Supported options are:
Print the values to the standard error stream.
Supported options are:
Returns a short one-line description of the application.
Returns a long description of the application.
Returns a copyright notice.
This module implements the server routine.
Implements the server routine.
The routine starts an HTTP server that serves HTSQL requests over the specified database.
This module implements the shell routine.
Describes a shell command.
This is the base abtract class for all shell commands. To create a concrete command, subclass Cmd, declare the command name and other parameters, and override execute().
The following class attributes could be overridden.
Instances of Cmd have the following attributes.
Returns an (informal) signature of the command.
Returns a short one-line description of the command.
Returns a long description of the command.
Executes the command.
The normal return value is None; any other value causes the shell to exit.
Implements the help command.
Implements the exit command.
Implements the user command.
Implements the headers command.
Implements the pager command.
Implements the common methods of get and post commands.
Implements the get command.
Implements the post command.
Implements the run command.
Holds mutable shell parameters.
Implements the shell routine.
Returns a notice to display when the shell is started.
Returns the shell description used by the help command.
Returns a long description of the routine.
Returns the shell command by name.
This module implements the version routine.