Package qm :: Package test :: Package web :: Module web :: Class QMTestServer
[hide private]
[frames] | no frames]

Class QMTestServer

source code

SocketServer.BaseServer --+                
                          |                
     SocketServer.TCPServer --+            
                              |            
      BaseHTTPServer.HTTPServer --+        
                                  |        
                     web.HTTPServer --+    
                                      |    
                          web.WebServer --+
                                          |
                                         QMTestServer

A 'QMTestServer' is the web GUI interface to QMTest.

Instance Methods [hide private]
 
__init__(self, database, port, address, log_file, targets, context, expectations, run_db)
Create and bind an HTTP server.
source code
 
GetContext(self)
Return the 'Context' in which tests will be run.
source code
 
GetDatabase(self)
Return the 'Database' handled by this server.
source code
 
GetRunDatabase(self)
Return the 'RunDatabase' handled by this server.
source code
 
GetExpectationDatabase(self)
Return the current ExpectationDatabase.
source code
 
GetExpectedOutcomes(self)
Return the current expected outcomes for the test database.
source code
 
GetHTMLClassForOutcome(self, outcome)
Return the CSS class for the 'outcome'.
source code
 
GetResultsStream(self)
Return the 'StorageResultsStream' containing test results.
source code
 
HandleClearResults(self, request)
Handle a request to clear the current test results.
source code
 
HandleCreateSuite(self, request)
Handle a submission of a new test suite.
source code
 
HandleDeleteItem(self, request)
Handle a request to delete a test or resource.
source code
 
HandleDeleteSuite(self, request)
Handle a request to delete a test suite.
source code
 
HandleDir(self, request)
Generate a directory page.
source code
 
HandleDirReport(self, request)
Generate a directory report page.
source code
 
HandleEditContext(self, request)
Handle a request to edit the context.
source code
 
HandleEditSuite(self, request)
Generate the page for editing a test suite.
source code
 
HandleLoadContext(self, request)
Handle a request to upload a context file.
source code
 
HandleLoadExpectations(self, request)
Handle a request to upload results.
source code
 
HandleLoadResults(self, request)
Handle a request to upload results.
source code
 
HandleNewResource(self, request)
Handle a request to create a new test.
source code
 
HandleNewTest(self, request)
Handle a request to create a new test.
source code
 
HandleNewSuite(self, request)
Handle a request to create a new suite.
source code
 
HandleRunTests(self, request)
Handle a request to run tests.
source code
 
HandleSaveContext(self, request)
Handlea request to save the context to a file.
source code
 
HandleSaveExpectations(self, request)
Handle a request to save expectations to a file.
source code
 
HandleSaveResults(self, request)
Handle a request to save results to a file.
source code
 
HandleSetExpectation(self, request)
Handle a request to set expectations.
source code
 
HandleShowItem(self, request)
Handle a request to show a test or resource.
source code
 
HandleShowResult(self, request)
Handle a request to show result detail.
source code
 
HandleShowResults(self, request)
Handle a request to show results.
source code
 
HandleShowItemReport(self, request)
Handle a request to show a test or resource report.
source code
 
HandleShowResultReport(self, request)
Handle a request to show result report.
source code
 
HandleShowSuite(self, request, edit=0)
Generate the page for displaying or editing a test suite.
source code
 
HandleShutdown(self, request)
Handle a request to shut down the server.
source code
 
HandleStopTests(self, request)
Handle a request to stop test execution.
source code
 
HandleSubmitContext(self, request)
Handle a context submission..
source code
 
HandleSubmitContextFile(self, request)
Handle a context file submission..
source code
 
HandleSubmitExpectation(self, request)
Handle setting a single expectation.
source code
 
HandleSubmitExpectations(self, request)
Handle uploading expected results.
source code
 
HandleSubmitExpectationsForm(self, request)
Handle uploading expected results.
source code
 
HandleSubmitItem(self, request)
Handle a test or resource submission.
source code
 
HandleSubmitResults(self, request)
Handle uploading results.
source code
 
HandleSubmitSuite(self, request)
Handle test suite submission.
source code
 
MakeNewTest(self, test_class_name, test_id)
Create a new test with default arguments.
source code
 
MakeNewResource(self, resource_class_name, resource_id)
Create a new resource with default arguments.
source code
 
_HandleRoot(self, request)
Handle the '/' URL.
source code
 
_ClosePopupAndRedirect(self, url)
Close the current window.
source code

Inherited from web.WebServer: Bind, CachePage, GetCachedPage, GetServerAddress, GetTemporaryAttachmentStore, HandleNoSessionError, IsScript, LogMessage, MakeButtonForCachedPopup, MakeConfirmationDialog, MakePopupDialog, ProcessScript, RegisterPathTranslation, RegisterScript, RequestShutdown, Run, TranslateRequest, handle_error

Inherited from web.WebServer (private): _HandleProblems

Inherited from web.HTTPServer: server_bind

Inherited from SocketServer.TCPServer: close_request, fileno, get_request, server_activate, server_close, shutdown_request

Inherited from SocketServer.BaseServer: finish_request, handle_request, handle_timeout, process_request, serve_forever, shutdown, verify_request

Inherited from SocketServer.BaseServer (private): _handle_request_noblock

Class Variables [hide private]

Inherited from BaseHTTPServer.HTTPServer: allow_reuse_address

Inherited from SocketServer.TCPServer: address_family, request_queue_size, socket_type

Inherited from SocketServer.BaseServer: timeout

Method Details [hide private]

__init__(self, database, port, address, log_file, targets, context, expectations, run_db)
(Constructor)

source code 

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.

Overrides: SocketServer.BaseServer.__init__

GetContext(self)

source code 

Return the 'Context' in which tests will be run.

returns -- The 'Context' in which tests will be run.

GetDatabase(self)

source code 

Return the 'Database' handled by this server.

returns -- The 'Database' handled by this server.

GetRunDatabase(self)

source code 

Return the 'RunDatabase' handled by this server.

returns -- The 'RunDatabase' handled by this server.

GetExpectationDatabase(self)

source code 

Return the current ExpectationDatabase.

returns -- The ExpectationDatabase instance.

GetExpectedOutcomes(self)

source code 

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(self, outcome)

source code 

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(self)

source code 

Return the 'StorageResultsStream' containing test results.

returns -- The 'StorageResultsStream' associated with this server.

HandleClearResults(self, request)

source code 

Handle a request to clear the current test results.

'request' -- A 'WebRequest' object.

HandleCreateSuite(self, request)

source code 

Handle a submission of a new test suite.

'request' -- A 'WebRequest' object.

HandleDeleteItem(self, request)

source code 

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.

HandleDeleteSuite(self, request)

source code 

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.

HandleDir(self, request)

source code 

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.

HandleDirReport(self, request)

source code 

Generate a directory report 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(self, request)

source code 

Handle a request to edit the context.

'request' -- The 'WebRequest' that caused the event.

HandleLoadContext(self, request)

source code 

Handle a request to upload a context file.

'request' -- The 'WebRequest' that caused the event.

HandleLoadExpectations(self, request)

source code 

Handle a request to upload results.

'request' -- The 'WebRequest' that caused the event.

HandleLoadResults(self, request)

source code 

Handle a request to upload results.

'request' -- The 'WebRequest' that caused the event.

HandleNewResource(self, request)

source code 

Handle a request to create a new test.

'request' -- The 'WebRequest' that caused the event.

HandleNewTest(self, request)

source code 

Handle a request to create a new test.

'request' -- The 'WebRequest' that caused the event.

HandleNewSuite(self, request)

source code 

Handle a request to create a new suite.

'request' -- The 'WebRequest' that caused the event.

HandleRunTests(self, request)

source code 
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(self, request)

source code 

Handlea request to save the context to a file.

'request' -- The 'WebRequest' that caused the event.

HandleSaveExpectations(self, request)

source code 

Handle a request to save expectations to a file.

'request' -- The 'WebRequest' that caused the event.

HandleSaveResults(self, request)

source code 

Handle a request to save results to a file.

'request' -- The 'WebRequest' that caused the event.

HandleSetExpectation(self, request)

source code 

Handle a request to set expectations.

'request' -- A 'WebRequest' object.

HandleShowItem(self, request)

source code 
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(self, request)

source code 

Handle a request to show result detail. If a 'test_run' argument was provided, fetch the result from the corresponding test run. Else read it from the results stream.

'request' -- The 'WebRequest' that caused the event.

HandleShowResults(self, request)

source code 

Handle a request to show results.

'request' -- The 'WebRequest' that caused the event.

HandleShowItemReport(self, request)

source code 
Handle a request to show a test or resource report.

'request' -- A 'WebRequest' object.

This function generates pages to handle these requests:

  'show-test' -- Display a test.

  'show-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.

HandleShowResultReport(self, request)

source code 

Handle a request to show result report.

'request' -- The 'WebRequest' that caused the event.

HandleShowSuite(self, request, edit=0)

source code 
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(self, request)

source code 

Handle a request to shut down the server.

'request' -- The 'WebRequest' that caused the event.

HandleStopTests(self, request)

source code 

Handle a request to stop test execution.

'request' -- The 'WebRequest' that caused the event.

HandleSubmitContext(self, request)

source code 

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(self, request)

source code 

Handle a context file submission..

'request' -- The 'WebRequest' that caused the event.

HandleSubmitExpectation(self, request)

source code 

Handle setting a single expectation.

'request' -- The 'WebRequest' that caused the event.

HandleSubmitExpectations(self, request)

source code 

Handle uploading expected results.

'request' -- The 'WebRequest' that caused the event.

HandleSubmitExpectationsForm(self, request)

source code 

Handle uploading expected results.

'request' -- The 'WebRequest' that caused the event.

HandleSubmitItem(self, request)

source code 

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(self, request)

source code 

Handle uploading results.

'request' -- The 'WebRequest' that caused the event.

HandleSubmitSuite(self, request)

source code 
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.

MakeNewTest(self, test_class_name, test_id)

source code 

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.

MakeNewResource(self, resource_class_name, resource_id)

source code 

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.

_HandleRoot(self, request)

source code 

Handle the '/' URL.

Overrides: web.WebServer._HandleRoot

_ClosePopupAndRedirect(self, url)

source code 

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'.