Exemple #1
0
    def test_lifecycle(self):
        """
        """
        core_controller = GACoreController(
            garuda_uuid='test-garuda',
            redis_info={
                'host': '127.0.0.1',
                'port': 6379,
                'db': 6
            },
            additional_controller_classes=[AdditionalController],
            authentication_plugins=[FakeAuthPlugin()])

        additional = core_controller.additional_controller(
            'test.controller.additional')

        self.assertTrue(additional.is_ready)

        core_controller.start()
        self.assertTrue(core_controller.running)
        self.assertTrue(additional.is_started)

        with self.assertRaises(RuntimeError):
            core_controller.start()

        core_controller.stop()
        self.assertFalse(core_controller.running)
        self.assertFalse(additional.is_started)

        with self.assertRaises(RuntimeError):
            core_controller.stop()
Exemple #2
0
    def test_publish(self):
        """
        """
        core_controller = GACoreController(garuda_uuid='test-garuda', redis_info={'host': '127.0.0.1', 'port': 6379, 'db': 6}, additional_controller_classes=[FakeController])
        controller = core_controller.additional_controller(identifier='the.id')

        def handler(data):
            self.assertEquals(data, 'hello')

        core_controller.start()
        controller.subscribe('test-channel', handler)
        controller.start_listening_to_events()
        controller.publish('test-channel', 'hello')
        controller.stop_listening_to_events()
        core_controller.stop()
Exemple #3
0
    def test_lifecycle(self):
        """
        """
        core_controller = GACoreController(garuda_uuid='test-garuda', redis_info={'host': '127.0.0.1', 'port': 6379, 'db': 6}, additional_controller_classes=[FakeController])
        controller = core_controller.additional_controller(identifier='the.id')

        self.assertIsNotNone(controller)
        self.assertFalse(controller.is_started)
        self.assertTrue(controller.is_ready)

        core_controller.start()
        self.assertTrue(controller.is_started)
        self.assertTrue(controller.is_ready)

        core_controller.stop()
        self.assertFalse(controller.is_started)
        self.assertTrue(controller.is_ready)
Exemple #4
0
    def test_publish(self):
        """
        """
        core_controller = GACoreController(
            garuda_uuid='test-garuda',
            redis_info={
                'host': '127.0.0.1',
                'port': 6379,
                'db': 6
            },
            additional_controller_classes=[FakeController])
        controller = core_controller.additional_controller(identifier='the.id')

        def handler(data):
            self.assertEquals(data, 'hello')

        core_controller.start()
        controller.subscribe('test-channel', handler)
        controller.start_listening_to_events()
        controller.publish('test-channel', 'hello')
        controller.stop_listening_to_events()
        core_controller.stop()
    def test_lifecycle(self):
        """
        """
        core_controller = GACoreController(garuda_uuid='test-garuda', redis_info={'host': '127.0.0.1', 'port': 6379, 'db': 6},
                                           additional_controller_classes=[AdditionalController], authentication_plugins=[FakeAuthPlugin()])

        additional = core_controller.additional_controller('test.controller.additional')

        self.assertTrue(additional.is_ready)

        core_controller.start()
        self.assertTrue(core_controller.running)
        self.assertTrue(additional.is_started)

        with self.assertRaises(RuntimeError):
            core_controller.start()

        core_controller.stop()
        self.assertFalse(core_controller.running)
        self.assertFalse(additional.is_started)

        with self.assertRaises(RuntimeError):
            core_controller.stop()
Exemple #6
0
    def test_lifecycle(self):
        """
        """
        core_controller = GACoreController(
            garuda_uuid='test-garuda',
            redis_info={
                'host': '127.0.0.1',
                'port': 6379,
                'db': 6
            },
            additional_controller_classes=[FakeController])
        controller = core_controller.additional_controller(identifier='the.id')

        self.assertIsNotNone(controller)
        self.assertFalse(controller.is_started)
        self.assertTrue(controller.is_ready)

        core_controller.start()
        self.assertTrue(controller.is_started)
        self.assertTrue(controller.is_ready)

        core_controller.stop()
        self.assertFalse(controller.is_started)
        self.assertTrue(controller.is_ready)