Exemplo n.º 1
0
 def handler(message):
     Persist(filename=self.persist_filename)
     store = MessageStore(self.persist, self.config.message_store_path)
     self.assertEqual(store.get_server_sequence(),
                      self.message_counter)
     self.message_counter += 1
     handled.append(True)
Exemplo n.º 2
0
 def test_reset_exchange_token_on_failure(self):
     """
     If an exchange fails we set the value of the next exchange token to
     C{None}, so we can authenticate ourselves even if we couldn't receive
     a valid token.
     """
     self.mstore.set_exchange_token("abcd-efgh")
     self.mstore.commit()
     self.transport.exchange = lambda *args, **kwargs: None
     self.exchanger.exchange()
     # Check that the change was persisted
     persist = Persist(filename=self.persist_filename)
     store = MessageStore(persist, self.config.message_store_path)
     self.assertIs(None, store.get_exchange_token())
Exemplo n.º 3
0
    def test_commit(self):
        """
        The Message Store can be told to save its persistent data to disk on
        demand.
        """
        filename = self.makeFile()
        store = MessageStore(Persist(filename=filename), self.temp_dir)
        store.set_accepted_types(["foo", "bar"])

        self.assertFalse(os.path.exists(filename))
        store.commit()
        self.assertTrue(os.path.exists(filename))

        store = MessageStore(Persist(filename=filename), self.temp_dir)
        self.assertEqual(set(store.get_accepted_types()), set(["foo", "bar"]))
Exemplo n.º 4
0
 def create_store(self):
     persist = Persist(filename=self.persist_filename)
     store = MessageStore(persist, self.temp_dir, 20)
     store.set_accepted_types(["empty", "data", "resynchronize"])
     store.add_schema(Message("empty", {}))
     store.add_schema(Message("empty2", {}))
     store.add_schema(Message("data", {"data": Bytes()}))
     store.add_schema(Message("unaccepted", {"data": Bytes()}))
     store.add_schema(Message("resynchronize", {}))
     return store
Exemplo n.º 5
0
 def handler(message):
     persist = Persist(filename=self.persist_filename)
     store = MessageStore(persist, self.config.message_store_path)
     self.assertEqual(store.get_pending_offset(), 1)
     self.assertEqual(store.get_sequence(), 1)
     handled.append(True)