Table of Contents

Class: FileDatabase qm/test/file_database.py

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.

Base Classes   
Database
Methods   
GetIds
GetResource
GetResourcePath
GetRoot
GetSubdirectories
GetSuite
GetSuitePath
GetTest
GetTestPath
RemoveExtension
_AreLabelsPaths
_GetLabelFromBasename
_GetLabels
_GetPath
_GetPathFromLabel
_GetRelativeLabelPath
_GetResourceFromPath
_GetSuiteFromPath
_GetTestFromPath
_IsFile
_IsResourceFile
_IsSuiteFile
_IsTestFile
  GetIds 
GetIds (
        self,
        kind,
        directory="",
        scan_subdirs=1,
        )

  GetResource 
GetResource ( self,  resource_id )

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.

Exceptions   
NoSuchResourceError, resource_id
  GetResourcePath 
GetResourcePath ( self,  resource_id )

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.

  GetRoot 
GetRoot ( self )

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

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.
  GetSuite 
GetSuite ( self,  suite_id )

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.
Exceptions   
NoSuchSuiteError, suite_id
  GetSuitePath 
GetSuitePath ( self,  suite_id )

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.

  GetTest 
GetTest ( self,  test_id )

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.
Exceptions   
NoSuchTestError, test_id
  GetTestPath 
GetTestPath ( self,  test_id )

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.

  RemoveExtension 
RemoveExtension (
        self,
        id,
        kind,
        )

Exceptions   
{ Database.RESOURCE : NoSuchResourceError, Database.TEST : NoSuchTestError, Database.SUITE : NoSuchSuiteError } [ kind ], id
  _AreLabelsPaths 
_AreLabelsPaths ( self )

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.
  _GetLabelFromBasename 
_GetLabelFromBasename ( self,  basename )

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 
_GetLabels (
        self,
        directory,
        scan_subdirs,
        label,
        predicate,
        )

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.
  _GetPath 
_GetPath (
        self,
        kind,
        id,
        )

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.
  _GetPathFromLabel 
_GetPathFromLabel ( self,  label )

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.
  _GetRelativeLabelPath 
_GetRelativeLabelPath ( self,  label )

Returns a representation of label as a relative filename.

returns
A relative filename corresponding to label.
  _GetResourceFromPath 
_GetResourceFromPath (
        self,
        resource_id,
        path,
        )

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.

Exceptions   
NotImplementedError
  _GetSuiteFromPath 
_GetSuiteFromPath (
        self,
        suite_id,
        path,
        )

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.

Exceptions   
NotImplementedError
  _GetTestFromPath 
_GetTestFromPath (
        self,
        test_id,
        path,
        )

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.

Exceptions   
NotImplementedError
  _IsFile 
_IsFile (
        self,
        kind,
        path,
        )

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.

  _IsResourceFile 
_IsResourceFile ( self,  path )

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.

Exceptions   
NotImplementedError
  _IsSuiteFile 
_IsSuiteFile ( self,  path )

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.

Exceptions   
NotImplementedError
  _IsTestFile 
_IsTestFile ( self,  path )

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.

Exceptions   
NotImplementedError

Table of Contents

This document was automatically generated on Mon Jan 3 09:42:29 2005 by HappyDoc version 2.1