Package qm :: Package test :: Package classes :: Module mount_database :: Class MountDatabase
[hide private]
[frames] | no frames]

Class MountDatabase

source code

         object --+        
                  |        
extension.Extension --+    
                      |    
      database.Database --+
                          |
                         MountDatabase

A 'MountDatabase' contains other databases.

Every contained database has a "mount point", which is a label giving the root of the database. A test with the ID "x" in a database with a mount point of "y" has the ID "x.y" in the containing database.

The contained databases are found by looking for subdirectories of the 'MountDatabase' directory. Every immediate subdirectory which is itself a QMTest database is mounted; its mount point is the name of the subdirectory.

Nested Classes [hide private]
  MountedSuite
A 'MountedSuite' is a suite from a mounted database.

Inherited from extension.Extension: Type, __metaclass__

Instance Methods [hide private]
 
__init__(self, path, arguments)
Construct a 'Database'.
source code
 
GetIds(self, kind, directory='', scan_subdirs=1)
Return all IDs of the indicated 'kind' that begin with 'directory'.
source code
 
GetTest(self, test_id)
Return the 'TestDescriptor' for the test named 'test_id'.
source code
 
GetResource(self, resource_id)
Return the 'ResourceDescriptor' for the resource 'resouce_id'.
source code
 
GetSuite(self, suite_id)
Return the 'Suite' for the suite named 'suite_id'.
source code
 
GetSubdirectories(self, directory)
Return the immediate subdirectories of 'directory'.
source code
 
GetClassPaths(self)
Return directories to search for test and resource classes.
source code
 
_AdjustResources(self, joiner, arguments)
Adjust the resource IDs stored in the 'arguments'.
source code
 
_GetContainedItem(self, kind, item_id)
Return 'item_id' from a mounted database.
source code
 
_SelectDatabase(self, item_id)
Return the contained database in which 'item_id' can be found.
source code

Inherited from database.Database: ExpandIds, GetAttachmentStore, GetConfigurationDirectory, GetExtension, GetExtensions, GetItem, GetLabelComponents, GetPath, GetResourceClassNames, GetResourceIds, GetSuiteIds, GetTestClassNames, GetTestIds, HasResource, HasSuite, HasTest, IsModifiable, IsValidLabel, JoinLabels, RemoveExtension, SplitLabel, SplitLabelLeft, WriteExtension

Inherited from extension.Extension: GetClassName, GetExplicitArguments, MakeDomDocument, MakeDomElement, Write, __getattr__

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  mounts = None
hash(x)
  _argument_dictionary = {'label_class': <<class 'qm.fields.Text...
A map from argument names to 'Field' instances.
  _argument_list = [<<class 'qm.fields.DictionaryField'> mounts>...
A list of all the 'Field's in this class.

Inherited from database.Database: ITEM_KINDS, RESOURCE, SUITE, TEST, arguments, kind, label_class, modifiable

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, path, arguments)
(Constructor)

source code 

Construct a 'Database'.

'path' -- A string containing the absolute path to the directory containing the database.

'arguments' -- A dictionary mapping attribute names to values. The use of this parameter is deprecated. Use keyword arguments instead.

Derived classes must call this method from their own '__init__' methods. Every derived class must have an '__init__' method that takes the path to the directory containing the database as its only argument. The path provided to the derived class '__init__' function will always be an absolute path.

Overrides: object.__init__
(inherited documentation)

GetIds(self, kind, directory='', scan_subdirs=1)

source code 

Return all IDs of the indicated 'kind' that begin with 'directory'.

'kind' -- One of the 'ITEM_KINDS'.

'directory' -- A label indicating the directory in which to begin the search.

'scan_subdirs' -- True if (and only if) subdirectories of 'directory' should be scanned.

returns -- A list of all items of the indicated 'kind' located within 'directory', as absolute labels.

Derived classes may override this method.

Overrides: database.Database.GetIds
(inherited documentation)

GetTest(self, test_id)

source code 

Return the 'TestDescriptor' for the test named 'test_id'.

'test_id' -- A label naming the test.

returns -- A 'TestDescriptor' corresponding to 'test_id'.

raises -- 'NoSuchTestError' if there is no test in the database named 'test_id'.

Overrides: database.Database.GetTest
(inherited documentation)

GetResource(self, resource_id)

source code 

Return the 'ResourceDescriptor' for the resource 'resouce_id'.

'resource_id' -- A label naming the resource.

returns -- A 'ResourceDescriptor' corresponding to 'resource_id'.

raises -- 'NoSuchResourceError' if there is no resource in the database named 'resource_id'.

Overrides: database.Database.GetResource
(inherited documentation)

GetSuite(self, suite_id)

source code 

Return the 'Suite' for the suite named 'suite_id'.

'suite_id' -- A label naming the suite.

returns -- An instance of 'Suite' (or a derived class of 'Suite') corresponding to 'suite_id'.

raises -- 'NoSuchSuiteError' if there is no test in the database named 'test_id'.

All databases must have an implicit suite called '' that contains all tests in the database. More generally, for each directory in the database, there must be a corresponding suite that contains all tests in that directory and its subdirectories.

Overrides: database.Database.GetSuite
(inherited documentation)

GetSubdirectories(self, directory)

source code 

Return the immediate subdirectories of 'directory'.

'directory' -- A label indicating a directory in the database.

returns -- A sequence of (relative) labels indictating the immediate subdirectories of 'directory'. For example, if "a.b" and "a.c" are directories in the database, this method will return "b" and "c" given "a" as 'directory'.

Derived classes may override this method.

Overrides: database.Database.GetSubdirectories
(inherited documentation)

GetClassPaths(self)

source code 

Return directories to search for test and resource classes.

returns -- A sequence of strings. Each string is a directory that should be searched to locate test and resource classes. The directories will be searched in the order they appear. QMTest will search other directories (like those in the 'QMTEST_CLASS_PATH' environment variable) in addition to these directories.

For a given database, this method should always return the same value; callers are permitted to cache the value returned.

Derived classes may override this method. The sequence returned by the derived class need not be a superset of the value returned by the default implementation (but probably should be).

Overrides: database.Database.GetClassPaths
(inherited documentation)

_AdjustResources(self, joiner, arguments)

source code 

Adjust the resource IDs stored in the 'arguments'.

'joiner' -- A function of one argument which prepends the label for a mount point to the label it is given.

'arguments' -- The arguments to a test or resource class.

Modifies the arguments to contain resource names that are relative to the containing database.

_GetContainedItem(self, kind, item_id)

source code 

Return 'item_id' from a mounted database.

'kind' -- The kind of item to return.

'item_id' -- The name of the item, in the containing database.

returns -- A tuple '(joiner, item). The 'item' will be from one of the mounted databases. 'joiner' is a function of one argument which prepends the mount point to its argument.

_SelectDatabase(self, item_id)

source code 

Return the contained database in which 'item_id' can be found.

'item_id' -- The name of an item in this database.

returns -- A tuple '(database, joiner, id)' where 'database' is a 'Database', 'joiner' is a function of one argument which prepends the mount point to a label, and 'id' is the portion of 'item_id' that remains after stripping off the mount point of 'database'. If 'item_id' does not correspond to any mount point, an exception is raised.


Class Variable Details [hide private]

_argument_dictionary

A map from argument names to 'Field' instances.

A map from the names of arguments for this class to the corresponding 'Field'.

Value:
{'label_class': <<class 'qm.fields.TextField'> label_class>,
 'modifiable': <<class 'qm.fields.BooleanField'> modifiable>,
 'mounts': <<class 'qm.fields.DictionaryField'> mounts>}

_argument_list

A list of all the 'Field's in this class.

This list combines the complete list of 'arguments'. 'Field's appear in the order reached by a pre-order breadth-first traversal of the hierarchy, starting from the most derived class.

Value:
[<<class 'qm.fields.DictionaryField'> mounts>,
 <<class 'qm.fields.TextField'> label_class>,
 <<class 'qm.fields.BooleanField'> modifiable>]