Methods
|
|
|
|
GetContext
|
GetContext ( self )
Return the Context in which tests will be run.
- returns
- The
Context in which tests will be run.
|
|
GetDatabase
|
GetDatabase ( self )
Return the Database handled by this server.
- returns
- The
Database handled by this server.
|
|
GetExpectedOutcomes
|
GetExpectedOutcomes ( self )
Return the current expected outcomes for the test database.
- returns
- A map from test IDs to outcomes. Some tests may have
not have an entry in the map.
|
|
GetHTMLClassForOutcome
|
GetHTMLClassForOutcome ( self, outcome )
Return the CSS class for the outcome .
-
outcome
- One of the result outcomes.
- returns
- The name of a CSS class. These are used with <span>
elements. See
qm.css .
|
|
GetResultsStream
|
GetResultsStream ( self )
Return the StorageResultsStream containing test results.
- returns
- The
StorageResultsStream associated with this
server.
|
|
HandleClearResults
|
HandleClearResults ( self, request )
Handle a request to clear the current test results.
-
request
- A
WebRequest object.
|
|
HandleCreateSuite
|
HandleCreateSuite ( self, request )
Handle a submission of a new test suite.
-
request
- A
WebRequest object.
|
|
HandleDeleteItem
|
HandleDeleteItem ( self, request )
Handle a request to delete a test or resource.
This function handles the script requests delete-test and
delete-resource .
-
request
- A
WebRequest object.
The ID of the test or resource to delete is specified in the id
field of the request.
Exceptions
|
|
RuntimeError, "unrecognized script name"
qm.web.HttpRedirect, request
|
|
|
HandleDeleteSuite
|
HandleDeleteSuite ( self, request )
Handle a request to delete a test suite.
-
request
- A
WebRequest object.
The ID of the suite to delete is specified in the id field of the
request.
Exceptions
|
|
qm.web.HttpRedirect, qm.web.WebRequest( "dir", base = request )
|
|
|
HandleDir
|
HandleDir ( self, request )
Generate a directory page.
-
request
- A
WebRequest object.
The request has these fields:
-
path
- A path in test/resource/suite ID space. If specified,
only tests and resources in this subtree are displayed, and their
IDs are displayed relative to this path. If omitted, the entire
contents of the test database are shown.
|
|
HandleEditContext
|
HandleEditContext ( self, request )
Handle a request to edit the context.
-
request
- The
WebRequest that caused the event.
|
|
HandleEditSuite
|
HandleEditSuite ( self, request )
Generate the page for editing a test suite.
|
|
HandleLoadContext
|
HandleLoadContext ( self, request )
Handle a request to upload a context file.
-
request
- The
WebRequest that caused the event.
|
|
HandleLoadExpectations
|
HandleLoadExpectations ( self, request )
Handle a request to upload results.
-
request
- The
WebRequest that caused the event.
|
|
HandleLoadResults
|
HandleLoadResults ( self, request )
Handle a request to upload results.
-
request
- The
WebRequest that caused the event.
|
|
HandleNewResource
|
HandleNewResource ( self, request )
Handle a request to create a new test.
-
request
- The
WebRequest that caused the event.
|
|
HandleNewSuite
|
HandleNewSuite ( self, request )
Handle a request to create a new suite.
-
request
- The
WebRequest that caused the event.
|
|
HandleNewTest
|
HandleNewTest ( self, request )
Handle a request to create a new test.
-
request
- The
WebRequest that caused the event.
|
|
HandleRunTests
|
HandleRunTests ( self, request )
Handle a request to run tests.
-
request
- The
WebRequest that caused the event.
These fields in request are used:
-
ids
- A comma-separated list of test and suite IDs. These IDs
are expanded into the list of IDs of tests to run.
|
|
HandleSaveContext
|
HandleSaveContext ( self, request )
Handlea request to save the context to a file.
-
request
- The
WebRequest that caused the event.
|
|
HandleSaveExpectations
|
HandleSaveExpectations ( self, request )
Handle a request to save expectations to a file.
-
request
- The
WebRequest that caused the event.
|
|
HandleSaveResults
|
HandleSaveResults ( self, request )
Handle a request to save results to a file.
-
request
- The
WebRequest that caused the event.
|
|
HandleSetExpectation
|
HandleSetExpectation ( self, request )
Handle a request to set expectations.
-
request
- A
WebRequest object.
|
|
HandleShowItem
|
HandleShowItem ( self, request )
Handle a request to show a test or resource.
-
request
- A
WebRequest object.
This function generates pages to handle these requests:
-
create-test
- Generate a form for initial editing of a test
about to be created, given its test ID and test class.
-
create-resource
- Likewise for an resource.
-
show-test
- Display a test.
-
show-resource
- Likewise for an resource.
-
edit-test
- Generate a form for editing an existing test.
-
edit-resource
- Likewise for an resource.
This function distinguishes among these cases by checking the script
name of the request object.
The request must have the following fields:
-
id
- A test or resource ID. For show or edit pages, the ID of an
existing item. For create pages, the ID of the item being
created.
-
class
- For create pages, the name of the test or resource
class.
|
|
HandleShowResult
|
HandleShowResult ( self, request )
Handle a request to show result detail.
-
request
- The
WebRequest that caused the event.
|
|
HandleShowResults
|
HandleShowResults ( self, request )
Handle a request to show results.
-
request
- The
WebRequest that caused the event.
|
|
HandleShowSuite
|
HandleShowSuite (
self,
request,
edit=0,
)
Generate the page for displaying or editing a test suite.
-
request
- A
WebRequest object.
-
edit
- If true, display the page for editing the suite.
Otherwise, just display the suite.
The request has the following fields:
-
id
- The ID of the suite to display or edit.
|
|
HandleShutdown
|
HandleShutdown ( self, request )
Handle a request to shut down the server.
-
request
- The
WebRequest that caused the event.
|
|
HandleStopTests
|
HandleStopTests ( self, request )
Handle a request to stop test execution.
-
request
- The
WebRequest that caused the event.
|
|
HandleSubmitContext
|
HandleSubmitContext ( self, request )
Handle a context submission..
-
request
- The
WebRequest that caused the event. The
request must have a context_vars key, whose value is the
the context variables.
|
|
HandleSubmitContextFile
|
HandleSubmitContextFile ( self, request )
Handle a context file submission..
-
request
- The
WebRequest that caused the event.
|
|
HandleSubmitExpectation
|
HandleSubmitExpectation ( self, request )
Handle setting a single expectation.
-
request
- The
WebRequest that caused the event.
|
|
HandleSubmitExpectations
|
HandleSubmitExpectations ( self, request )
Handle uploading expected results.
-
request
- The
WebRequest that caused the event.
|
|
HandleSubmitExpectationsForm
|
HandleSubmitExpectationsForm ( self, request )
Handle uploading expected results.
-
request
- The
WebRequest that caused the event.
|
|
HandleSubmitItem
|
HandleSubmitItem ( self, request )
Handle a test or resource submission.
This function handles submission of the test or resource editing form
generated by handle_show . The script name in request should be
submit-test or submit-resource . It constructs the appropriate
Test or Resource object and writes it to the database, either as a
new item or overwriting an existing item.
The request must have the following form fields:
-
id
- The test or resource ID of the item being edited or created.
-
class
- The name of the test or resource class of this item.
- arguments
- Argument values are encoded in fields whose names start
with
qm.fields.Field.form_field_prefix .
|
|
HandleSubmitResults
|
HandleSubmitResults ( self, request )
Handle uploading results.
-
request
- The
WebRequest that caused the event.
|
|
HandleSubmitSuite
|
HandleSubmitSuite ( self, request )
Handle test suite submission.
-
request
- A
WebRequest object.
The request object has these fields:
-
id
- The ID of the test suite being edited. If a suite with
this ID exists, it is replaced (it must not be an implicit suite
though). Otherwise a new suite is edited.
-
test_ids
- A comma-separated list of test IDs to include in the
suite, relative to the suite's own ID.
-
suite_ids
- A comma-separated list of other test suite IDs to
include in the suite, relative to the suite's own ID.
Exceptions
|
|
qm.web.HttpRedirect, qm.web.WebRequest( "show-suite", base = request, id = suite_id )
|
|
|
MakeNewResource
|
MakeNewResource (
self,
resource_class_name,
resource_id,
)
Create a new resource with default arguments.
-
resource_class_name
- The name of the resource class of which to
create a new resource.
-
resource_id
- The resource ID of the new resource.
- returns
- A new
ResourceDescriptor object.
Exceptions
|
|
RuntimeError, qm.error( "resource already exists", resource_id = resource_id )
|
|
|
MakeNewTest
|
MakeNewTest (
self,
test_class_name,
test_id,
)
Create a new test with default arguments.
-
test_class_name
- The name of the test class of which to create a
new test.
-
test_id
- The test ID of the new test.
- returns
- A new
TestDescriptor object.
Exceptions
|
|
RuntimeError, qm.error( "test already exists", test_id = test_id )
|
|
|
_ClosePopupAndRedirect
|
_ClosePopupAndRedirect ( self, url )
Close the current window. Redirect the main window to url .
-
url
- A string giving the URL to which the main window should
be redirected.
- returns
- A string giving HTML that will close the current
window and redirect the main window to
url .
|
|
_HandleRoot
|
_HandleRoot ( self, request )
Handle the / URL.
Exceptions
|
|
qm.web.HttpRedirect, qm.web.WebRequest( "/test/dir" )
|
|
|
__init__
|
__init__ (
self,
database,
port,
address,
log_file,
targets,
context,
expectations,
)
Create and bind an HTTP server.
-
database
- The test database to serve.
-
port
- The port number on which to accept HTTP requests.
-
address
- The local address to which to bind the server. An
empty string indicates all local addresses.
-
log_file
- A file object to which the server will log requests.
None for no logging.
-
targets
- A sequence of
Target objects to use when running
tests.
-
context
- The
Context in which tests will execute.
Exceptions
|
|
RuntimeError, qm.error( "address in use", address = address )
RuntimeError, qm.error( "privileged port", port = port )
|
|