Package qm :: Package test :: Package classes :: Module xml_database :: Class XMLDatabase
[hide private]
[frames] | no frames]

Class XMLDatabase

source code

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

A database representing tests as XML files in a directory tree.

Nested Classes [hide private]

Inherited from extension.Extension: Type, __metaclass__

Instance Methods [hide private]
 
__init__(self, path, arguments)
Construct a 'Database'.
source code
 
_GetTestFromPath(self, test_id, test_path)
Return a descriptor for the test given by 'path'.
source code
 
_GetResourceFromPath(self, resource_id, resource_path)
Return a descriptor for the resource given by 'path'.
source code
 
__StoreAttachments(self, item)
Store all attachments in 'item' in the attachment store.
source code
 
__MakeDataFilePath(self, item_id, file_name)
Construct the path to an attachment data file.
source code
 
__LoadItem(self, item_id, path, document_parser)
Load an item (a test or resource) from an XML file.
source code
 
__ParseTestDocument(self, test_id, document)
Return a test object constructed from a test document.
source code
 
__ParseResourceDocument(self, resource_id, document)
Return a resource object constructed from a resource document.
source code
 
_GetSuiteFromPath(self, suite_id, path)
Load the test suite file at 'path' with suite ID 'suite_id'.
source code
 
WriteExtension(self, id, extension)
Store 'extension' in the database, using the name 'id'.
source code
 
GetAttachmentStore(self)
Returns the 'AttachmentStore' associated with the database.
source code
 
_Trace(self, message)
Write a trace 'message'.
source code

Inherited from file_database.ExtensionDatabase: GetResourceExtension, GetResourcePath, GetSuiteExtension, GetSuitePath, GetTestExtension, GetTestPath

Inherited from file_database.ExtensionDatabase (private): _GetLabelFromBasename, _GetPathFromLabel, _GetRelativeLabelPath, _IsResourceFile, _IsSuiteFile, _IsTestFile

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

Inherited from file_database.FileDatabase (private): _AreLabelsPaths, _GetLabels, _GetPath, _IsFile

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

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]

Inherited from file_database.ExtensionDatabase: arguments

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)
(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)

_GetTestFromPath(self, test_id, test_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.

Overrides: file_database.FileDatabase._GetTestFromPath
(inherited documentation)

_GetResourceFromPath(self, resource_id, resource_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.

Overrides: file_database.FileDatabase._GetResourceFromPath
(inherited documentation)

__StoreAttachments(self, item)

source code 

Store all attachments in 'item' in the attachment store.

'item' -- A 'Test' or 'Resource'. If any of its fields contain attachments, add them to the 'AttachmentStore'.

__MakeDataFilePath(self, item_id, file_name)

source code 

Construct the path to an attachment data file.

'item_id' -- The test or resource item of which the attachment is part.

'file_name' -- The file name specified for the attachment.

__LoadItem(self, item_id, path, document_parser)

source code 

Load an item (a test or resource) from an XML file.

This function is used for logic common to tests and resources.

'item_id' -- The ID of the item to get.

'path' -- The path to the test or resource file.

'document_parser' -- A function that takes an XML DOM document as its argument and returns the constructed item object.

__ParseTestDocument(self, test_id, document)

source code 

Return a test object constructed from a test document.

'test_id' -- The test ID of the test.

'document' -- A DOM document containing a single test element from which the test is constructed.

__ParseResourceDocument(self, resource_id, document)

source code 

Return a resource object constructed from a resource document.

'resource_id' -- The resource ID of the resource.

'document' -- A DOM document node containing a single resource element from which the resource object is constructed.

_GetSuiteFromPath(self, suite_id, path)

source code 

Load the test suite file at 'path' with suite ID 'suite_id'.

returns -- A 'Suite' object.

Overrides: file_database.FileDatabase._GetSuiteFromPath

WriteExtension(self, id, extension)

source code 

Store 'extension' in the database, using the name 'id'.

'id' -- A label for the 'extension'.

'extension' -- An instance of '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'.

Overrides: database.Database.WriteExtension
(inherited documentation)

GetAttachmentStore(self)

source code 

Returns the 'AttachmentStore' associated with the database.

returns -- The 'AttachmentStore' containing the attachments associated with tests and resources in this database.

Overrides: database.Database.GetAttachmentStore

_Trace(self, message)

source code 

Write a trace 'message'.

'message' -- A string to be output as a trace message.