def test_onlyInstallPowerups(self): """ Make sure onlyInstallPowerups doesn't load dependencies or prohibit multiple calls. """ foo = Kitchen(store=self.store) e = Toaster(store=self.store) f = Toaster(store=self.store) dependency.onlyInstallPowerups(e, foo) dependency.onlyInstallPowerups(f, foo) self.assertEquals(list(foo.powerupsFor(IBreadConsumer)), [e, f]) self.assertEquals( list(self.store.query(dependency._DependencyConnector)), [])
def test_onlyInstallPowerups(self): """ Make sure onlyInstallPowerups doesn't load dependencies or prohibit multiple calls. """ foo = Kitchen(store=self.store) e = Toaster(store=self.store) f = Toaster(store=self.store) dependency.onlyInstallPowerups(e, foo) dependency.onlyInstallPowerups(f, foo) self.assertEquals(list(foo.powerupsFor(IBreadConsumer)), [e, f]) self.assertEquals(list(self.store.query( dependency._DependencyConnector)), [])
def postOptions(self): siteStore = self.parent.getStore() # Make sure the base mantissa offering is installed. offeringTech = ixmantissa.IOfferingTechnician(siteStore) offerings = offeringTech.getInstalledOfferingNames() if baseOffering.name not in offerings: raise UsageError( "This command can only be used on Mantissa databases.") # It is, we can make some simplifying assumptions. Specifically, # there is exactly one SiteConfiguration installed. site = siteStore.findUnique(SiteConfiguration) if self['http-log'] is not None: if self['http-log']: site.httpLog = siteStore.filesdir.preauthChild( self['http-log']) else: site.httpLog = None if self['hostname'] is not None: if self['hostname']: site.hostname = self.decodeCommandLine(self['hostname']) else: raise UsageError("Hostname may not be empty.") if self['urchin-key'] is not None: # Install the API key for Google Analytics, to enable tracking for # this site. APIKey.setKeyForAPI( siteStore, APIKey.URCHIN, self['urchin-key'].decode('ascii')) # Set up whatever static content was requested. for webPath, filePath in self.staticPaths: staticSite = siteStore.findFirst( StaticSite, StaticSite.prefixURL == webPath) if staticSite is not None: staticSite.staticContentPath = filePath else: staticSite = StaticSite( store=siteStore, staticContentPath=filePath, prefixURL=webPath, sessionless=True) onlyInstallPowerups(staticSite, siteStore)