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

Class FileDatabase

source code

         object --+        
                  |        
extension.Extension --+    
                      |    
      database.Database --+
                          |
                         FileDatabase
Known Subclasses:

A 'FileDatabase' stores each test as a single file.

A 'FileDatabase' is a 'Database' that stores each test, suite, or resource as a single file. In addition, some subdirectories can be considered implicit suites. The contents of the implicit suite are all of the tests and suites contained in the subdirectory.

'FileDatabase' is an abstract class.

Nested Classes [hide private]

Inherited from extension.Extension: Type, __metaclass__

Instance Methods [hide private]
 
GetTest(self, test_id)
Return the 'TestDescriptor' for the test named 'test_id'.
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
 
GetSuite(self, suite_id)
Return the 'Suite' for the suite named 'suite_id'.
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
 
GetResource(self, resource_id)
Return the 'ResourceDescriptor' for the resource named 'resource_id'.
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
 
GetRoot(self)
Return the root of the test database.
source code
 
GetSubdirectories(self, directory)
Return the subdirectories of 'directory'.
source code
 
GetIds(self, kind, directory='', scan_subdirs=1)
Return all IDs of the indicated 'kind' that begin with 'directory'.
source code
 
_GetPath(self, kind, id)
Returns the file system path corresponding to 'id'.
source code
 
_IsFile(self, kind, path)
Returns true if 'path' is a file of the indicated 'kind'.
source code
 
_GetTestFromPath(self, test_id, path)
Return a descriptor for the test given by 'path'.
source code
 
_GetSuiteFromPath(self, suite_id, path)
Return a the 'Suite' given by 'path'.
source code
 
_GetResourceFromPath(self, resource_id, path)
Return a descriptor for the resource given by 'path'.
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
 
_GetLabels(self, directory, scan_subdirs, label, predicate)
Returns the labels of entities in 'directory'.
source code
 
RemoveExtension(self, id, kind)
Remove the extension 'id' from the database.
source code
 
_AreLabelsPaths(self)
Returns true if labels are to be thought of as file names.
source code
 
_GetRelativeLabelPath(self, label)
Returns a representation of 'label' as a relative filename.
source code

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, __init__

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]
  _argument_list = [<<class 'qm.fields.TextField'> label_class>,...
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]

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

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.

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

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 suite in the database named 'suite_id'.

Overrides: database.Database.GetSuite

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.

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

GetResource(self, resource_id)

source code 

Return the 'ResourceDescriptor' for the resource named 'resource_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

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.

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

GetRoot(self)

source code 

Return the root of the test database.

returns -- The directory that serves as the root of the test database. All paths are relative to this directory.

Derived classes may override this method.

GetSubdirectories(self, directory)

source code 

Return the subdirectories of 'directory'.

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

returns -- A sequence of (relative) labels indictating the 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'.

Overrides: database.Database.GetSubdirectories

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)

_GetPath(self, kind, id)

source code 

Returns the file system path corresponding to 'id'.

'kind' -- An extension kind.

'id' -- The name of the entity.

returns -- The path in which the entity is stored.

_IsFile(self, kind, path)

source code 

Returns true if 'path' is a file of the indicated 'kind'.

'kind' -- One of 'Database.ITEM_KINDS'.

'path' -- The path to a file.

returns -- True iff 'path' is a file of the indicated kind.

Derived classes must override this method.

_GetTestFromPath(self, test_id, path)

source code 

Return a descriptor for the test given by 'path'.

'test_id' -- The label naming the test.

'path' -- An absolute path to a test file. The 'path' satisfies '_IsTestFile'.

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

Derived classes must override this method.

_GetSuiteFromPath(self, suite_id, path)

source code 

Return a the 'Suite' given by 'path'.

'suite_id' -- The label naming the suite.

'path' -- An absolute path to a suite file. The 'path' satisfies '_IsSuiteFile' and is a file, not a directory.

returns -- A 'Suite' corresponding to 'suite_id'.

Derived classes must override this method.

_GetResourceFromPath(self, resource_id, path)

source code 

Return a descriptor for the resource given by 'path'.

'resource_id' -- The label naming the resource.

'path' -- An absolute path to a resource file. The 'path' satisfies '_IsResourceFile'.

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

Derived classes must override this method.

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

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

_GetLabels(self, directory, scan_subdirs, label, predicate)

source code 

Returns the labels of entities in 'directory'.

'directory' -- The absolute path name of the directory in which to begin the search.

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

'label' -- The label that corresponds to 'directory'.

'predicate' -- A function that takes a file name and returns a boolean.

returns -- Labels for all file names in 'directory'. that satisfy 'predicate' If 'scan_subdirs' is true, subdirectories are scanned as well.

RemoveExtension(self, id, kind)

source code 

Remove the extension 'id' from the database.

'id' -- A label for the 'Extension' instance stored in the database.

'kind' -- The kind of 'Extension' stored with the given 'id'.

Overrides: database.Database.RemoveExtension
(inherited documentation)

_AreLabelsPaths(self)

source code 

Returns true if labels are to be thought of as file names.

returns -- True if labels are to be thought of as file names. If this predicate holds, every label is a path, relative to the root of the database. If false, the labels are translated to paths by adding the 'suite_extension' between directories and the 'test_extension' or 'resource_extension' at the end of the name.

_GetRelativeLabelPath(self, label)

source code 

Returns a representation of 'label' as a relative filename.

returns -- A relative filename corresponding to 'label'.


Class Variable Details [hide private]

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