def postOptions(self): for o in offering.getOfferings(): if o.name == self["offering"]: offering.installOffering(self.store, o, None) break else: raise usage.UsageError("No such offering")
def setUp(self): """ Set up a store with a valid offering to test against. """ self.store = Store() installOffering(self.store, baseOffering, {}) self.site = ISiteURLGenerator(self.store)
def test_buildTerminalProtocol(self): """ L{ImaginaryApp.buildTerminalProtocol} returns a L{CharacterSelectionTextServer} instance with a role representing the store it is in, a reference to the L{ImaginaryWorld} installed on the Imaginary application store, and a list of L{Thing} items shared to the role. """ # XXX This is too many stores for a unit test to need to create. siteStore = Store(filesdir=FilePath(self.mktemp())) Mantissa().installSite(siteStore, u'example.com', u'', False) installOffering(siteStore, imaginaryOffering, {}) login = siteStore.findUnique(LoginSystem) account = login.addAccount(u'alice', u'example.com', u'password') userStore = account.avatars.open() app = ImaginaryApp(store=userStore) installOn(app, userStore) imaginary = login.accountByAddress(u'Imaginary', None).avatars.open() world = imaginary.findUnique(ImaginaryWorld) # Alice connects to her own ImaginaryApp (all that is possible at the # moment). viewer = _AuthenticatedShellViewer(getAccountNames(userStore)) proto = app.buildTerminalProtocol(viewer) self.assertIdentical(proto.world, world) self.assertEqual(proto.role.externalID, u'*****@*****.**') self.assertEqual(proto.choices, [])
def test_getInstalledThemes(self): """ Test that only themes which belong to offerings installed on a particular store are returned by L{xmantissa.webtheme.getInstalledThemes}. """ s = Store() self.assertEquals(getInstalledThemes(s), []) installOffering(s, baseOffering, {}) installedThemes = getInstalledThemes(s) self.assertEquals(len(installedThemes), 1) self.failUnless(isinstance(installedThemes[0], MantissaTheme))
def test_switchFrontPage(self): """ 'axiomatic frontpage <offeringName>' switches the primary application (i.e., the one whose front page will be displayed on the site's root resource) to the one belonging to the named offering. """ off2 = Offering( name=u"test_offering2", description=u"Offering for creating a sample app store", siteRequirements=[], appPowerups=[TestAppPowerup], installablePowerups=[], loginInterfaces=[], themes=[], ) installedOffering2 = installOffering(self.siteStore, off2, None) sfp = SetFrontPage() sfp.parent = self sfp.parseOptions(["test_offering"]) resource, segments = self.frontPage.produceResource(None, ("",), self.webViewer) result, segs = resource.locateChild(None, [""]) self.assertIdentical(result.fragment.original.store, self.substore) self.assertEqual(segs, []) sfp.parseOptions(["test_offering2"]) resource, moreSegs = self.frontPage.produceResource(None, ("",), self.webViewer) result, segs = resource.locateChild(None, [""]) self.assertEqual(segs, []) self.assertIdentical(result.fragment.original.store, installedOffering2.application.open()) self.assertRaises(UsageError, sfp.parseOptions, []) self.assertRaises(UsageError, sfp.parseOptions, ["nonexistent"])
def test_switchFrontPage(self): """ 'axiomatic frontpage <offeringName>' switches the primary application (i.e., the one whose front page will be displayed on the site's root resource) to the one belonging to the named offering. """ off2 = Offering( name=u'test_offering2', description=u'Offering for creating a sample app store', siteRequirements=[], appPowerups=[TestAppPowerup], installablePowerups=[], loginInterfaces=[], themes=[]) installedOffering2 = installOffering(self.siteStore, off2, None) sfp = SetFrontPage() sfp.parent = self sfp.parseOptions(["test_offering"]) resource, segments = self.frontPage.produceResource( None, ('', ), self.webViewer) result, segs = resource.locateChild(None, ['']) self.assertIdentical(result.fragment.original.store, self.substore) self.assertEqual(segs, []) sfp.parseOptions(["test_offering2"]) resource, moreSegs = self.frontPage.produceResource( None, ('', ), self.webViewer) result, segs = resource.locateChild(None, ['']) self.assertEqual(segs, []) self.assertIdentical(result.fragment.original.store, installedOffering2.application.open()) self.assertRaises(UsageError, sfp.parseOptions, []) self.assertRaises(UsageError, sfp.parseOptions, ["nonexistent"])
def buildWorld(testCase): """ Build a L{TestWorld}. """ # XXX This is too many stores for a unit test to need to create. siteStore = Store(filesdir=FilePath(testCase.mktemp())) Mantissa().installSite(siteStore, u'example.com', u'', False) installOffering(siteStore, imaginaryOffering, {}) login = siteStore.findUnique(LoginSystem) account = login.addAccount(u'alice', u'example.com', u'password') userStore = account.avatars.open() app = ImaginaryApp(store=userStore) installOn(app, userStore) imaginary = login.accountByAddress(u'Imaginary', None).avatars.open() world = imaginary.findUnique(ImaginaryWorld) # Alice connects to her own ImaginaryApp (all that is possible at the # moment). viewer = _AuthenticatedShellViewer(getAccountNames(userStore)) return TestWorld(proto=app.buildTerminalProtocol(viewer), world=world)
def setUp(self): """ Set up a store with an installed offering. """ self.siteStore = Store(dbdir=self.mktemp()) Mantissa().installSite(self.siteStore, u"localhost", u"", False) off = Offering( name=u"test_offering", description=u"Offering for creating a sample app store", siteRequirements=[], appPowerups=[TestAppPowerup], installablePowerups=[], loginInterfaces=[], themes=[], ) self.installedOffering = installOffering(self.siteStore, off, None) self.app = self.installedOffering.application self.substore = self.app.open() sharedItem = getEveryoneRole(self.substore).getShare(getDefaultShareID(self.substore)) self.frontPage = self.siteStore.findUnique(FrontPage) self.webViewer = IWebViewer(self.siteStore)
def setUp(self): """ Set up a store with an installed offering. """ self.siteStore = Store(dbdir=self.mktemp()) Mantissa().installSite(self.siteStore, u"localhost", u"", False) off = Offering( name=u'test_offering', description=u'Offering for creating a sample app store', siteRequirements=[], appPowerups=[TestAppPowerup], installablePowerups=[], loginInterfaces=[], themes=[], ) self.installedOffering = installOffering(self.siteStore, off, None) self.app = self.installedOffering.application self.substore = self.app.open() sharedItem = getEveryoneRole(self.substore).getShare( getDefaultShareID(self.substore)) self.frontPage = self.siteStore.findUnique(FrontPage) self.webViewer = IWebViewer(self.siteStore)
def setUp(self): """ Set up a site store with the base offering installed. """ self.siteStore = Store() installOffering(self.siteStore, baseOffering, {})