Exemple #1
0
 def setUp(self):
     cap_table = CapTable(unserializer=None)
     cap_table.add(EntryPointStub(), cap=u'foo')
     self.clock = Clock()
     self.transport = FakeWebSocketTransport()
     self.protocol = WebSocketDispatcherProtocol(
         caps=cap_table.as_unenumerable_collection(),
         subscription_context=SubscriptionContext(reactor=self.clock, poller=None))
     self.protocol.transport = self.transport
Exemple #2
0
 def setUp(self):
     cap_table = CapTable(unserializer=None)
     cap_table.add(EntryPointStub(), cap=u'foo')
     self.clock = Clock()
     self.transport = FakeWebSocketTransport()
     self.protocol = OurStreamProtocol(
         caps=cap_table.as_unenumerable_collection(),
         subscription_context=SubscriptionContext(reactor=self.clock,
                                                  poller=None))
     self.protocol.transport = self.transport
Exemple #3
0
        def make_service(app):
            # TODO: Temporary glue while we refactor for multisession
            session = app.get_session()
            cap_table = CapTable(lambda bogus: bogus)
            if root_cap is None:
                cap_table.add(session, cap=UNIQUE_PUBLIC_CAP)
                root_cap_subst = UNIQUE_PUBLIC_CAP
            else:
                cap_table.add(session, cap=root_cap)
                root_cap_subst = root_cap

            from shinysdr.i.network.app import WebService
            return WebService(reactor=self.reactor,
                              cap_table=cap_table.as_unenumerable_collection(),
                              http_endpoint=http_endpoint,
                              ws_endpoint=ws_endpoint,
                              root_cap=root_cap_subst,
                              title=title)
Exemple #4
0
 def make_service(app):
     # TODO: Temporary glue while we refactor for multisession
     session = app.get_session()
     cap_table = CapTable(lambda bogus: bogus)
     if root_cap is None:
         cap_table.add(session, cap=UNIQUE_PUBLIC_CAP)
         root_cap_subst = UNIQUE_PUBLIC_CAP
     else:
         cap_table.add(session, cap=root_cap)
         root_cap_subst = root_cap
     
     from shinysdr.i.network.app import WebService
     return WebService(
         reactor=self.reactor,
         cap_table=cap_table.as_unenumerable_collection(),
         flowgraph_for_debug=app.get_receive_flowgraph(),  # TODO: Once we have the diagnostics or admin page however that turns out to work, this goes away
         read_only_dbs=self.databases._get_read_only_databases(),
         writable_db=self.databases._get_writable_database(),
         http_endpoint=http_endpoint,
         ws_endpoint=ws_endpoint,
         root_cap=root_cap_subst,
         title=title)
Exemple #5
0
 def make_service(app):
     # TODO: Temporary glue while we refactor for multisession
     session = app.get_session()
     cap_table = CapTable(lambda bogus: bogus)
     if root_cap is None:
         cap_table.add(session, cap=UNIQUE_PUBLIC_CAP)
         root_cap_subst = UNIQUE_PUBLIC_CAP
     else:
         cap_table.add(session, cap=root_cap)
         root_cap_subst = root_cap
     
     from shinysdr.i.network.webapp import WebService
     return WebService(
         reactor=self.reactor,
         cap_table=cap_table.as_unenumerable_collection(),
         http_endpoint=http_endpoint,
         ws_endpoint=ws_endpoint,
         root_cap=root_cap_subst,
         title=title)
Exemple #6
0
 def make_service(app):
     # TODO: Temporary glue while we refactor for multisession
     session = app.get_session()
     cap_table = CapTable(lambda bogus: bogus)
     if root_cap is None:
         cap_table.add(session, cap=UNIQUE_PUBLIC_CAP)
         root_cap_subst = UNIQUE_PUBLIC_CAP
     else:
         cap_table.add(session, cap=root_cap)
         root_cap_subst = root_cap
     
     from shinysdr.i.network.app import WebService
     return WebService(
         reactor=self.reactor,
         cap_table=cap_table.as_unenumerable_collection(),
         flowgraph_for_debug=app.get_receive_flowgraph(),  # TODO: Once we have the diagnostics or admin page however that turns out to work, this goes away
         read_only_dbs=self.databases._get_read_only_databases(),
         writable_db=self.databases._get_writable_database(),
         http_endpoint=http_endpoint,
         ws_endpoint=ws_endpoint,
         root_cap=root_cap_subst,
         title=title)
Exemple #7
0
 def setUp(self):
     self.t = CapTable(self.__unserializer)
Exemple #8
0
class TestCapTable(unittest.TestCase):
    def setUp(self):
        self.t = CapTable(self.__unserializer)
    
    def __unserializer(self, state):
        return unserialize_exported_state(BaseEntryPointStub, state)
    
    def test_slug(self):
        cap = self.t.add(BaseEntryPointStub(), slug='foo')
        self.assertSubstring('foo-', cap)
    
    def test_persistence(self):
        stub = BaseEntryPointStub()
        cap = self.t.add(stub)
        state = self.t.as_persistable().state_to_json()
        self.tearDown()
        self.setUp()
        self.t.as_persistable().state_from_json(state)
        self.assertEqual(stub.get_serial_number(), self.t.as_unenumerable_collection()[cap].get_serial_number())
    
    def test_deletion(self):
        stub = DeletableStub()
        cap = self.t.add(stub)
        self.assertTrue(cap in self.t.as_unenumerable_collection())
        
        # hidden when deleted flag is set
        stub.set_deleted(True)
        self.assertFalse(cap in self.t.as_unenumerable_collection())
        
        # but not actually removed (to avoid iterate/delete conflicts)
        stub.set_deleted(False)
        self.assertTrue(cap in self.t.as_unenumerable_collection())
        
        # and actually removed after a garbage_collect
        stub.set_deleted(True)
        self.t.garbage_collect()
        stub.set_deleted(False)
        self.assertFalse(cap in self.t.as_unenumerable_collection())
Exemple #9
0
 def setUp(self):
     self.t = CapTable(self.__unserializer)
Exemple #10
0
class TestCapTable(unittest.TestCase):
    def setUp(self):
        self.t = CapTable(self.__unserializer)

    def __unserializer(self, state):
        return unserialize_exported_state(BaseEntryPointStub, state)

    def test_slug(self):
        cap = self.t.add(BaseEntryPointStub(), slug='foo')
        self.assertSubstring('foo-', cap)

    def test_persistence(self):
        stub = BaseEntryPointStub()
        cap = self.t.add(stub)
        state = self.t.as_persistable().state_to_json()
        self.tearDown()
        self.setUp()
        self.t.as_persistable().state_from_json(state)
        self.assertEqual(
            stub.get_serial_number(),
            self.t.as_unenumerable_collection()[cap].get_serial_number())

    def test_deletion(self):
        stub = DeletableStub()
        cap = self.t.add(stub)
        self.assertTrue(cap in self.t.as_unenumerable_collection())

        # hidden when deleted flag is set
        stub.set_deleted(True)
        self.assertFalse(cap in self.t.as_unenumerable_collection())

        # but not actually removed (to avoid iterate/delete conflicts)
        stub.set_deleted(False)
        self.assertTrue(cap in self.t.as_unenumerable_collection())

        # and actually removed after a garbage_collect
        stub.set_deleted(True)
        self.t.garbage_collect()
        stub.set_deleted(False)
        self.assertFalse(cap in self.t.as_unenumerable_collection())