Class: Database | qm/test/database.py | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A
|
Base Classes | |
---|---|
qm.extension.Extension |
Methods | |||
---|---|---|---|
ExpandIds | |||
ExpandIds ( self, ids ) Expand test and suite IDs into test IDs.
| |||
GetAttachmentStore | |||
GetAttachmentStore ( self ) Returns the
| |||
GetClassPaths | |||
GetClassPaths ( self ) Return directories to search for test and resource classes.
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). | |||
GetConfigurationDirectory | |||
GetConfigurationDirectory ( self ) Return the directory containing configuration information.
Derived classes must not override this method. | |||
GetIds | |||
GetIds ( self, kind, directory="", scan_subdirs=1, ) Return all IDs of the indicated
| |||
GetItem | |||
GetItem ( self, kind, item_id, ) Return the item of the indicated
| |||
GetLabelComponents | |||
GetLabelComponents ( self, label ) Return all of the component directories of
| |||
GetPath | |||
GetPath ( self ) Return the directory containing the database.
Derived classes must not override this method. | |||
GetResource | |||
GetResource ( self, resource_id ) Return the
|
Exceptions | |
---|---|
NoSuchResourceError( resource_id ) |
GetResourceClassNames ( self )
Derived classes may override this method. The default implementation allows all available resource classes, but the derived class may allow only a subset.
GetResourceIds ( self, directory="", scan_subdirs=1, )
directory
.directory
scan_subdirs
directory
should be scanned.returns
directory
,
as absolute labels.GetSubdirectories ( self, directory )
directory
.directory
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.
GetSuite ( self, suite_id )
Suite
for the suite named suite_id
.suite_id
Suite
(or a derived class of
Suite
) corresponding to suite_id
.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.
Exceptions | |
---|---|
NoSuchSuiteError( suite_id ) |
GetSuiteIds ( self, directory="", scan_subdirs=1, )
directory
.directory
scan_subdirs
directory
should be scanned.returns
directory
,
as absolute labels.GetTest ( self, test_id )
TestDescriptor
for the test named test_id
.test_id
TestDescriptor
corresponding to test_id
.NoSuchTestError
if there is no test in the database
named test_id
.Exceptions | |
---|---|
NoSuchTestError( test_id ) |
GetTestClassNames ( self )
Derived classes may override this method. The default implementation allows all available test classes, but the derived class may allow only a subset.
GetTestIds ( self, directory="", scan_subdirs=1, )
directory
.directory
scan_subdirs
directory
should be scanned.returns
directory
,
as absolute labels.HasResource ( self, resource_id )
Check whether or not the database has a resource named
resource_id
.
resource_id
resource_id
. If this function returns true,
GetResource
will usually succeed. However, they may be
circumstances where HasResource
returns true and GetResource
does not succeed. For example, someone might remove a critical
file from the database between the time that HasResource
is
called and the time that GetResource
is called.Derived classes may override this method.
HasSuite ( self, suite_id )
suite_id
.suite_id
suite_id
. If this function returns true, GetSuite
will usually succeed. However, they may be circumstances where
HasSuite
returns true and GetSuite
does not succeed. For
example, someone might remove a critical file from the database
between the time that HasSuite
is called and the time that
GetSuite
is called.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.
Derived classes may override this method.
HasTest ( self, test_id )
test_id
.test_id
test_id
. If this function returns true, GetTest
will
usually succeed. However, they may be circumstances where
HasTest
returns true and GetTest
does not succeed. For
example, someone might remove a critical file from the database
between the time that HasTest
is called and the time that
GetTest
is called.Derived classes may override this method.
IsModifiable ( self )
Write
that make changes to the structure of the databaes itself.
Otherwise, the contents of the database may be viewed, but not
modified.IsValidLabel ( self, label, is_component=1, )
label
is valid.label
is_component
label
is a valid name for entities in this
database.JoinLabels ( self, *labels )
labels
together.labels
RemoveExtension ( self, id, kind, )
id
from the database.id
Extension
instance stored in the
database.kind
Extension
stored with the given id
.
Some databases store different kinds of Extension
in different
namespaces so that it is possible for there to be more than one
Extension
with the same id
in a single database.Exceptions | |
---|---|
NotImplementedError |
SplitLabel ( self, label )
(directory, basename)
.(directory, basename)
.SplitLabelLeft ( self, label )
Split the label into a pair (parent, subpath)
.
This is the same operation as SplitLabel, except the split
occurs at the leftmost separator, not the rightmost, and a
single-component label comes back in the parent slot.
(parent, subpath)
.WriteExtension ( self, id, extension, )
extension
in the database, using the name id
.id
extension
.extension
Extension
. The extension
is stored in the database. If there is a
previous item in the database with the same id', it is removed
and replaced with extension
. Some databases may not be able
to store all Extension
instances; those database must throw an
exception when an attempt is made to store such an
extension
.
Exceptions | |
---|---|
NotImplementedError |
__init__ ( self, path, arguments, )
Database
.path
arguments
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.