Ejemplo n.º 1
0
    def get_storage(config):
        #TODO here we set the configuration for storage
        if config.conversations.type == 'file':
            return ConversationFileStorage(config.conversations.storage)
        elif config.conversations.type == 'redis':
            return ConversationRedisStorage(config.conversations.storage)

        YLogger.warning(None, "Invalid Conversations file storage type [%s]", config.conversations.type)
        return None
Ejemplo n.º 2
0
    def test_persistence(self):

        storage_config = BotConversationsRedisStorageConfiguration("redis")
        redis = ConversationRedisStorage(storage_config)
        self.assertIsNotNone(redis)

        client = TestClient()
        client_context = client.create_client_context("testid")
        conversation1 = Conversation(client_context)
        conversation1.set_property("topic", "topic1")

        redis.save_conversation(conversation1, client_context.userid)

        conversation2 = Conversation(client_context)
        redis.load_conversation(conversation2, client_context.userid)
        self.assertIsNotNone(conversation2)
        self.assertIsNotNone(conversation2.properties)

        self.assertEquals(conversation1.properties, conversation2.properties)
Ejemplo n.º 3
0
    def get_storage(config):

        if config.conversations.type == 'file':
            return ConversationFileStorage(config.conversations.storage)
        elif config.conversations.type == 'redis':
            return ConversationRedisStorage(config.conversations.storage)

        if logging.getLogger().isEnabledFor(logging.ERROR):
            logging.warning("Invalid Conversations file storage type [%s]" %
                            config.conversations.type)
        return None
Ejemplo n.º 4
0
    def test_persistence(self):

        storage_config = BotConversationsRedisStorageConfiguration("redis")
        redis = ConversationRedisStorage(storage_config)
        self.assertIsNotNone(redis)

        client = TestClient()
        client_context = client.create_client_context("testid")
        conversation1 = Conversation(client_context)
        conversation1.set_property("topic", "topic1")

        redis.save_conversation(conversation1, client_context.userid)

        conversation2 = Conversation(client_context)
        redis.load_conversation(conversation2, client_context.userid)
        self.assertIsNotNone(conversation2)
        self.assertIsNotNone(conversation2.properties)

        self.assertEqual(conversation1.properties, conversation2.properties)