Beispiel #1
0
class TestScopedServers(TestCase):
    
    def setUp(self):
        self.manager = Manager()
        # Debugger().register(self.manager)
    
        self.server1 = BaseServer(("localhost", 8000), channel="site1") 
        self.server1.register(self.manager);
        ScopeDispatcher(channel="site1").register(self.server1)
        Root1().register(self.manager)
    
        self.server2 = BaseServer(("localhost", 8001), channel="site2") 
        self.server2.register(self.manager);
        ScopeDispatcher(channel="site2").register(self.server2)
        Root2().register(self.manager)
    
        self.manager.start()

    def tearDown(self):
        self.manager.stop()

    def test_access(self):
        f = urlopen(self.server1.base)
        s = f.read()
        self.assertEqual(s, b"Hello from site 1!")

        f = urlopen(self.server2.base)
        s = f.read()
        self.assertEqual(s, b"Hello from site 2!")
Beispiel #2
0
class TestScopedServers(TestCase):
    def setUp(self):
        self.manager = Manager()
        # Debugger().register(self.manager)

        self.server1 = BaseServer(("localhost", 8000), channel="site1")
        self.server1.register(self.manager)
        ScopeDispatcher(channel="site1").register(self.server1)
        Root1().register(self.manager)

        self.server2 = BaseServer(("localhost", 8001), channel="site2")
        self.server2.register(self.manager)
        ScopeDispatcher(channel="site2").register(self.server2)
        Root2().register(self.manager)

        self.manager.start()

    def tearDown(self):
        self.manager.stop()

    def test_access(self):
        f = urlopen(self.server1.base)
        s = f.read()
        self.assertEqual(s, b"Hello from site 1!")

        f = urlopen(self.server2.base)
        s = f.read()
        self.assertEqual(s, b"Hello from site 2!")
Beispiel #3
0
class TestVPathArgs(TestCase):
    def test_access(self):
        self.manager = Manager()
        Debugger().register(self.manager)

        self.server = BaseServer(("localhost", 8000))
        self.server.register(self.manager)
        Dispatcher().register(self.server)
        Root().register(self.manager)
        Leaf().register(self.manager)

        self.manager.start()

        f = urlopen(self.server.base + "/test.txt")
        s = f.read()
        self.assertEqual(s, b"Hello world!")

        f = urlopen(self.server.base + "/test/test.txt")
        s = f.read()
        self.assertEqual(s, b"Hello world!")

        self.manager.stop()
Beispiel #4
0
class TestVPathArgs(TestCase):

    def test_access(self):
        self.manager = Manager()
        Debugger().register(self.manager)
    
        self.server = BaseServer(("localhost", 8000)) 
        self.server.register(self.manager);
        Dispatcher().register(self.server)
        Root().register(self.manager)
        Leaf().register(self.manager)
    
        self.manager.start()

        f = urlopen(self.server.base + "/test.txt")
        s = f.read()
        self.assertEqual(s, b"Hello world!")

        f = urlopen(self.server.base + "/test/test.txt")
        s = f.read()
        self.assertEqual(s, b"Hello world!")

        self.manager.stop()