def test_data_persistence(self):
        """
        Test to make sure that assigning the `data` attribute of a MessengerAgent does
        not overwrite values already in `data`.
        """
        opt = self._get_args()
        opt.update(OPT)
        manager = MessengerManager(opt)
        agent = MessengerAgent(opt, manager, AGENT_ID, TASK_ID, PAGE_ID)

        self.assertEqual(agent.data, {'allow_images': False})
        agent.data = {'second_arg': False}
        self.assertEqual(agent.data, {
            'allow_images': False,
            'second_arg': False
        })
        agent.data['allow_images'] = True
        self.assertEqual(agent.data, {
            'allow_images': True,
            'second_arg': False
        }),
        agent.data = {'third_arg': 1, 'second_arg': True}
        self.assertEqual(agent.data, {
            'allow_images': True,
            'second_arg': True,
            'third_arg': 1
        })
Beispiel #2
0
def run(opt):
    """Run MessengerManager."""
    manager = MessengerManager(opt)
    try:
        manager.start_task()
    except BaseException:
        raise
    finally:
        manager.shutdown()
Beispiel #3
0
def run(opt):
    """Run MessengerManager."""
    opt['service'] = SERVICE_NAME
    manager = MessengerManager(opt)
    try:
        manager.start_task()
    except BaseException:
        raise
    finally:
        manager.shutdown()