Changeset 17 for trunk

Show
Ignore:
Timestamp:
08/10/05 12:50:36 (7 years ago)
Author:
mj
Message:

Add test of the only actual code present so far.

Location:
trunk/src/chronolog/keys
Files:
1 added
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/chronolog/keys/domainscollection.py

    r16 r17  
    4444 
    4545class DomainNameChooser(NameChooser): 
    46     """INameChooser adapter for ILocalTimeLogKeyDomainsCollections""" 
     46    """INameChooser adapter for ILocalTimeLogKeyDomainsCollections 
     47 
     48    This NameChooser uses the id of the domain objects passed in as the name 
     49    to be used. We'll use a mockup object to demonstrate this with: 
     50     
     51     >>> class DummyDomain: 
     52     ...     def __init__(self, id='foo'): 
     53     ...         self.id = id 
     54     ... 
     55 
     56    It'll refuse any name that is not the id of the domain object 
     57    outright: 
     58 
     59     >>> from chronolog.keys.domainscollection import DomainNameChooser 
     60     >>> chooser = DomainNameChooser({}) 
     61     >>> chooser.checkName('foo', DummyDomain()) 
     62     True 
     63     >>> chooser.checkName('bar', DummyDomain()) 
     64     Traceback (most recent call last): 
     65     ... 
     66     UserError: Given name and domain id do not match! 
     67      
     68    As stated, the choosen name will be taken from the domain object itself, 
     69    and the passed in name is ignored: 
     70     
     71     >>> chooser.chooseName('bar', DummyDomain()) 
     72     'foo' 
     73      
     74    """ 
    4775 
    4876    def checkName(self, name, object):