Package qm :: Package test :: Module file_database :: Class ExtensionDatabase
[hide private]
[frames] | no frames]

Class ExtensionDatabase

source code

         object --+            
                  |            
extension.Extension --+        
                      |        
      database.Database --+    
                          |    
               FileDatabase --+
                              |
                             ExtensionDatabase

An 'ExtensionDatabase' is a 'FileDatabase' where each kind of entity (test, suite, resource) has a particular extension. For example, if tests have the extension '.qmt', then all files ending with '.qmt' are considered tests. If an extension for a particular kind of entity is not specified or is the empty string, then all files will be considered to be that kind of entity.

'ExtensionDatabase' is an abstract class.

Nested Classes [hide private]

Inherited from extension.Extension: Type, __metaclass__

Instance Methods [hide private]
 
__init__(self, path, arguments=None, **args)
Construct a 'Database'.
source code
 
GetTestExtension(self)
Return the extension that indicates a file is a test.
source code
 
GetSuiteExtension(self)
Return the extension that indicates a file is a suite.
source code
 
GetResourceExtension(self)
Return the extension that indicates a file is a resource.
source code
 
GetTestPath(self, test_id)
Return the file containing 'test_id'.
source code
 
_IsTestFile(self, path)
Returns true if 'path' is a test file.
source code
 
GetSuitePath(self, suite_id)
Return the file containing 'suite_id'.
source code
 
_IsSuiteFile(self, path)
Returns true if 'path' is a test suite file or directory.
source code
 
GetResourcePath(self, resource_id)
Return the file containing 'resource_id'.
source code
 
_IsResourceFile(self, path)
Returns true if 'path' is a resource file.
source code
 
_GetPathFromLabel(self, label)
Returns the file system path corresponding to 'label'.
source code
 
_GetLabelFromBasename(self, basename)
Returns the label associated with a file named 'basename'.
source code
 
_GetRelativeLabelPath(self, label)
Returns a representation of 'label' as a filename.
source code

Inherited from FileDatabase: GetIds, GetResource, GetRoot, GetSubdirectories, GetSuite, GetTest, RemoveExtension

Inherited from database.Database: ExpandIds, GetAttachmentStore, GetClassPaths, GetConfigurationDirectory, GetExtension, GetExtensions, GetItem, GetLabelComponents, GetPath, GetResourceClassNames, GetResourceIds, GetSuiteIds, GetTestClassNames, GetTestIds, HasResource, HasSuite, HasTest, IsModifiable, IsValidLabel, JoinLabels, 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]
  arguments = [<<class 'qm.fields.TextField'> test_extension>, <...
A list of the arguments to the extension class.
  _argument_dictionary = {'label_class': <<class 'qm.fields.Text...
A map from argument names to 'Field' instances.
  _argument_list = [<<class 'qm.fields.TextField'> resource_exte...
A list of all the 'Field's in this class.
  resource_extension = '.qma'
  suite_extension = '.qms'
  test_extension = '.qmt'

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

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, path, arguments=None, **args)
(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)

GetTestExtension(self)

source code 

Return the extension that indicates a file is a test.

returns -- The extension (including the leading period) that indicates that a file is a test.

GetSuiteExtension(self)

source code 

Return the extension that indicates a file is a suite.

returns -- The extension (including the leading period) that indicates that a file is a suite.

GetResourceExtension(self)

source code 

Return the extension that indicates a file is a resource.

returns -- The extension (including the leading period) that indicates that a file is a resource.

GetTestPath(self, test_id)

source code 

Return the file containing 'test_id'.

'test_id' -- The name of a test.

returns -- The absolute file name of the file that contains, or would contain, 'test_id'. This method works even if no test named 'test_id' exists.

Derived classes may override this method.

Overrides: FileDatabase.GetTestPath
(inherited documentation)

_IsTestFile(self, path)

source code 

Returns true if 'path' is a test file.

'path' -- The absolute name of a file. All relevant components in the path name have already been checked to ensure that they are valid labels.

returns -- True iff the file corresponds to a test.

Derived classes must override this method.

Overrides: FileDatabase._IsTestFile
(inherited documentation)

GetSuitePath(self, suite_id)

source code 

Return the file containing 'suite_id'.

'suite_id' -- The name of a suite.

returns -- The absolute file name of the file (or directory) that contains, or would contain, 'suite_id'. This method works even if no suite named 'suite_id' exists.

Derived classes may override this method.

Overrides: FileDatabase.GetSuitePath
(inherited documentation)

_IsSuiteFile(self, path)

source code 

Returns true if 'path' is a test suite file or directory.

'path' -- The absolute name of a file. All relevant components in the path name have already been checked to ensure that they are valid labels.

returns -- True iff the file corresponds to a test.

Derived classes may override this method, but only to restrict the set of suites. In particular, a derived class method may return false where this method would return true, but never vice versa.

Derived classes must override this method.

Overrides: FileDatabase._IsSuiteFile
(inherited documentation)

GetResourcePath(self, resource_id)

source code 

Return the file containing 'resource_id'.

'resource_id' -- The name of a resource.

returns -- The absolute file name of the file that contains, or would contain, 'resource_id'. This method works even if no Resource named 'resource_id' exists.

Derived classes may override this method.

Overrides: FileDatabase.GetResourcePath
(inherited documentation)

_IsResourceFile(self, path)

source code 

Returns true if 'path' is a resource file.

'path' -- The absolute name of a file. All relevant components in the path name have already been checked to ensure that they are valid labels.

returns -- True iff the file corresponds to a resource.

Derived classes must override this method.

Overrides: FileDatabase._IsResourceFile
(inherited documentation)

_GetPathFromLabel(self, label)

source code 

Returns the file system path corresponding to 'label'.

'label' -- The id for a test, test suite, or similar entity.

returns -- The absolute path for the corresponding entry in the file system, but without any required extension.

Overrides: FileDatabase._GetPathFromLabel
(inherited documentation)

_GetLabelFromBasename(self, basename)

source code 

Returns the label associated with a file named 'basename'.

'basename' -- The basename of a file, including the extension.

returns -- The corresponding label.

Derived classes may override this method.

Overrides: FileDatabase._GetLabelFromBasename
(inherited documentation)

_GetRelativeLabelPath(self, label)

source code 

Returns a representation of 'label' as a filename.

returns -- A filename corresponding to 'label'.

Overrides: FileDatabase._GetRelativeLabelPath

Class Variable Details [hide private]

arguments

A list of the arguments to the extension class.

Each element of this list should be an instance of 'Field'. The 'Field' instance describes the argument.

Derived classes may redefine this class variable. However, derived classes should not explicitly include the arguments from base classes; QMTest will automatically combine all the arguments found throughout the class hierarchy.

Value:
[<<class 'qm.fields.TextField'> test_extension>,
 <<class 'qm.fields.TextField'> suite_extension>,
 <<class 'qm.fields.TextField'> resource_extension>]

_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>,
 'resource_extension': <<class 'qm.fields.TextField'> resource_extensi\
on>,
 'suite_extension': <<class 'qm.fields.TextField'> suite_extension>,
 'test_extension': <<class 'qm.fields.TextField'> test_extension>}

_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.TextField'> resource_extension>,
 <<class 'qm.fields.BooleanField'> modifiable>,
 <<class 'qm.fields.TextField'> test_extension>,
 <<class 'qm.fields.TextField'> label_class>,
 <<class 'qm.fields.TextField'> suite_extension>]