def buildTestDirectory(store, dataRoot, accounts=None, resources=None, augments=None, proxies=None, serversDB=None): """ @param store: the store for the directory to use @param dataRoot: the directory to copy xml files to @param accounts: path to the accounts.xml file @type accounts: L{FilePath} @param resources: path to the resources.xml file @type resources: L{FilePath} @param augments: path to the augments.xml file @type augments: L{FilePath} @param proxies: path to the proxies.xml file @type proxies: L{FilePath} @return: the directory service @rtype: L{IDirectoryService} """ defaultDirectory = FilePath(__file__).sibling("accounts") if accounts is None: accounts = defaultDirectory.child("accounts.xml") if resources is None: resources = defaultDirectory.child("resources.xml") if augments is None: augments = defaultDirectory.child("augments.xml") if proxies is None: proxies = defaultDirectory.child("proxies.xml") if not os.path.exists(dataRoot): os.makedirs(dataRoot) accountsCopy = FilePath(dataRoot).child("accounts.xml") accountsCopy.setContent(accounts.getContent()) resourcesCopy = FilePath(dataRoot).child("resources.xml") resourcesCopy.setContent(resources.getContent()) augmentsCopy = FilePath(dataRoot).child("augments.xml") augmentsCopy.setContent(augments.getContent()) proxiesCopy = FilePath(dataRoot).child("proxies.xml") proxiesCopy.setContent(proxies.getContent()) servicesInfo = ( ConfigDict({ "Enabled": True, "type": "xml", "params": { "xmlFile": "accounts.xml", "recordTypes": ("users", "groups"), }, }), ConfigDict({ "Enabled": True, "type": "xml", "params": { "xmlFile": "resources.xml", "recordTypes": ("locations", "resources", "addresses"), }, }), ) augmentServiceInfo = ConfigDict({ "type": "twistedcaldav.directory.augment.AugmentXMLDB", "params": { "xmlFiles": [ "augments.xml", ], "statSeconds": 15, }, }) wikiServiceInfo = ConfigDict({ "Enabled": True, "CollabHost": "localhost", "CollabPort": 4444, }) directory = buildDirectory(store, dataRoot, servicesInfo, augmentServiceInfo, wikiServiceInfo, serversDB) store.setDirectoryService(directory) return directory
def buildTestDirectory( store, dataRoot, accounts=None, resources=None, augments=None, proxies=None, serversDB=None ): """ @param store: the store for the directory to use @param dataRoot: the directory to copy xml files to @param accounts: path to the accounts.xml file @type accounts: L{FilePath} @param resources: path to the resources.xml file @type resources: L{FilePath} @param augments: path to the augments.xml file @type augments: L{FilePath} @param proxies: path to the proxies.xml file @type proxies: L{FilePath} @return: the directory service @rtype: L{IDirectoryService} """ defaultDirectory = FilePath(__file__).sibling("accounts") if accounts is None: accounts = defaultDirectory.child("accounts.xml") if resources is None: resources = defaultDirectory.child("resources.xml") if augments is None: augments = defaultDirectory.child("augments.xml") if proxies is None: proxies = defaultDirectory.child("proxies.xml") if not os.path.exists(dataRoot): os.makedirs(dataRoot) accountsCopy = FilePath(dataRoot).child("accounts.xml") accountsCopy.setContent(accounts.getContent()) resourcesCopy = FilePath(dataRoot).child("resources.xml") resourcesCopy.setContent(resources.getContent()) augmentsCopy = FilePath(dataRoot).child("augments.xml") augmentsCopy.setContent(augments.getContent()) proxiesCopy = FilePath(dataRoot).child("proxies.xml") proxiesCopy.setContent(proxies.getContent()) servicesInfo = ( ConfigDict( { "Enabled": True, "type": "xml", "params": { "xmlFile": "accounts.xml", "recordTypes": ("users", "groups"), }, } ), ConfigDict( { "Enabled": True, "type": "xml", "params": { "xmlFile": "resources.xml", "recordTypes": ("locations", "resources", "addresses"), }, } ), ) augmentServiceInfo = ConfigDict( { "type": "twistedcaldav.directory.augment.AugmentXMLDB", "params": { "xmlFiles": ["augments.xml", ], "statSeconds": 15, }, } ) wikiServiceInfo = ConfigDict( { "Enabled": True, "CollabHost": "localhost", "CollabPort": 4444, } ) directory = buildDirectory( store, dataRoot, servicesInfo, augmentServiceInfo, wikiServiceInfo, serversDB ) store.setDirectoryService(directory) return directory