Exemple #1
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, [])
Exemple #2
0
 def test_roleIn(self):
     """
     L{_AuthenticatedShellViewer.roleIn} returns a L{Role} for one of the
     account names passed to L{_AuthenticatedShellViewer.__init__}.
     """
     store = Store()
     viewer = _AuthenticatedShellViewer([(u"alice", u"example.com")])
     role = viewer.roleIn(store)
     self.assertEquals(role.externalID, u"*****@*****.**")
     self.assertIdentical(role.store, store)
Exemple #3
0
 def test_roleIn(self):
     """
     L{_AuthenticatedShellViewer.roleIn} returns a L{Role} for one of the
     account names passed to L{_AuthenticatedShellViewer.__init__}.
     """
     store = Store()
     viewer = _AuthenticatedShellViewer([(u"alice", u"example.com")])
     role = viewer.roleIn(store)
     self.assertEquals(role.externalID, u"*****@*****.**")
     self.assertIdentical(role.store, store)
Exemple #4
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)
Exemple #5
0
 def test_interface(self):
     """
     L{_AuthenticatedShellViewer} instances provide L{IViewer}.
     """
     self.assertTrue(verifyObject(IViewer, _AuthenticatedShellViewer([])))
Exemple #6
0
 def test_interface(self):
     """
     L{_AuthenticatedShellViewer} instances provide L{IViewer}.
     """
     self.assertTrue(verifyObject(IViewer, _AuthenticatedShellViewer([])))