Ejemplo n.º 1
0
 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")
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
 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")
Ejemplo n.º 5
0
    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, [])
Ejemplo n.º 6
0
    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))
Ejemplo n.º 7
0
    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))
Ejemplo n.º 8
0
    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"])
Ejemplo n.º 9
0
    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"])
Ejemplo n.º 10
0
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)
Ejemplo n.º 11
0
 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)
Ejemplo n.º 12
0
 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)
Ejemplo n.º 13
0
 def setUp(self):
     """
     Set up a site store with the base offering installed.
     """
     self.siteStore = Store()
     installOffering(self.siteStore, baseOffering, {})
Ejemplo n.º 14
0
 def setUp(self):
     """
     Set up a site store with the base offering installed.
     """
     self.siteStore = Store()
     installOffering(self.siteStore, baseOffering, {})