Beispiel #1
0
    def test_on_start(self):
        inlet1 = DummyInlet()
        outlet1 = DummyOutlet()
        link = Link([inlet1], [outlet1], timedelta(seconds=1))

        self.assertFalse(inlet1.active)
        self.assertFalse(outlet1.active)
        link.on_start()
        self.assertTrue(inlet1.active)
        self.assertTrue(outlet1.active)
Beispiel #2
0
    def test_on_start_already_active(self, inlet1, outlet1):
        type(inlet1).active = mock.PropertyMock(return_value=True)
        type(outlet1).active = mock.PropertyMock(return_value=True)
        link = Link([inlet1], [outlet1],
                    timedelta(seconds=1),
                    tags='test_on_start_already_active')

        link.on_start()

        inlet1.on_start.assert_not_called()
        outlet1.on_start.assert_not_called()
Beispiel #3
0
    def test_on_start(self, inlet1, outlet1):
        type(inlet1).active = mock.PropertyMock(return_value=False)
        type(outlet1).active = mock.PropertyMock(return_value=False)
        link = Link([inlet1], [outlet1],
                    timedelta(seconds=1),
                    name='test_on_start')

        link.on_start()

        inlet1.try_start.assert_called()
        outlet1.try_start.assert_called()
Beispiel #4
0
    def test_on_start_already_active(self):
        inlet1 = DummyInlet()
        outlet1 = DummyOutlet()
        inlet1.on_start = mock.Mock()
        outlet1.on_start = mock.Mock()
        inlet1._active = True
        outlet1._active = True
        link = Link([inlet1], [outlet1], timedelta(seconds=1))

        link.on_start()

        inlet1.on_start.assert_not_called()
        outlet1.on_start.assert_not_called()
Beispiel #5
0
    def test_on_start_inlet_exception_catch(self, inlet1, outlet1):
        inlet1.try_start.side_effect = lambda: exec('raise(RuntimeError())')
        link = Link([inlet1], [outlet1],
                    timedelta(seconds=1),
                    tags='test_on_start',
                    ignore_exceptions=True)

        with self.assertLogs(logging.getLogger('databay.Link'),
                             level='ERROR') as cm:
            link.on_start()
            self.assertTrue('on_start inlet exception: "" for inlet:' in
                            ';'.join(cm.output))

        inlet1.try_start.assert_called()
        outlet1.try_start.assert_called()