Пример #1
0
class HeartbeaterMockTest(PyonTestCase):
    """Tests which mock out parts of the EE Agent
    """

    def setUp(self):

        self.cfg = DotDict()
        self.cfg.eeagent = DotDict()
        self.cfg.eeagent.heartbeat = 1
        self.factory = Mock()

        self.process_id = 'fake'
        self.process = Mock()

        self.heartbeater = HeartBeater(self.cfg, self.factory, self.process_id, self.process)

    def tearDown(self):
        pass

    def test_heartbeater_waits_for_start(self):

        self.heartbeater.beat = Mock()

        self.heartbeater.poll()
        self.assertFalse(self.heartbeater.beat.called)

        self.heartbeater._started = True

        self.heartbeater.poll()
        self.assertTrue(self.heartbeater.beat.called)
Пример #2
0
    def setUp(self):

        self.cfg = DotDict()
        self.cfg.eeagent = DotDict()
        self.cfg.eeagent.heartbeat = 1
        self.factory = Mock()

        self.process_id = 'fake'
        self.process = DotDict()
        self.process._process = DotDict()
        self.process._process.heartbeat = Mock(return_value=self.heartbeater_not_ok)
        self.process._process.listeners = []

        self.heartbeater = HeartBeater(self.cfg, self.factory, self.process_id, self.process)
Пример #3
0
    def setUp(self):

        self.cfg = DotDict()
        self.cfg.eeagent = DotDict()
        self.cfg.eeagent.heartbeat = 1
        self.factory = Mock()

        self.process_id = 'fake'
        self.process = Mock()

        self.heartbeater = HeartBeater(self.cfg, self.factory, self.process_id, self.process)
Пример #4
0
class HeartbeaterMockTest(PyonTestCase):
    """Tests which mock out parts of the EE Agent
    """

    heartbeater_not_ok = (False, True, True)
    heartbeater_ok = (True, True, True)

    def setUp(self):

        self.cfg = DotDict()
        self.cfg.eeagent = DotDict()
        self.cfg.eeagent.heartbeat = 1
        self.factory = Mock()

        self.process_id = 'fake'
        self.process = DotDict()
        self.process._process = DotDict()
        self.process._process.heartbeat = Mock(
            return_value=self.heartbeater_not_ok)
        self.process._process.listeners = []

        self.heartbeater = HeartBeater(self.cfg, self.factory, self.process_id,
                                       self.process)

    def tearDown(self):
        pass

    def test_heartbeater_waits_for_start(self):

        self.heartbeater.beat = Mock()

        self.heartbeater.poll()
        self.assertFalse(self.heartbeater.beat.called)

        self.process._process.heartbeat = Mock(
            return_value=self.heartbeater_ok)

        self.heartbeater.poll()
        self.assertFalse(self.heartbeater.beat.called)

        self.process._process.listeners = ["listener"]
        self.process._process.heartbeat = Mock(
            return_value=self.heartbeater_not_ok)

        self.heartbeater.poll()
        self.assertFalse(self.heartbeater.beat.called)

        self.process._process.heartbeat = Mock(
            return_value=self.heartbeater_ok)
        self.heartbeater.poll()
        self.assertTrue(self.heartbeater.beat.called)
Пример #5
0
    def setUp(self):

        self.cfg = DotDict()
        self.cfg.eeagent = DotDict()
        self.cfg.eeagent.heartbeat = 1
        self.factory = Mock()

        self.process_id = "fake"
        self.process = DotDict()
        self.process._process = DotDict()
        self.process._process.heartbeat = Mock(return_value=self.heartbeater_not_ok)

        self.heartbeater = HeartBeater(self.cfg, self.factory, self.process_id, self.process)
Пример #6
0
class HeartbeaterMockTest(PyonTestCase):
    """Tests which mock out parts of the EE Agent
    """

    heartbeater_not_ok = (False, True, True)
    heartbeater_ok = (True, True, True)

    def setUp(self):

        self.cfg = DotDict()
        self.cfg.eeagent = DotDict()
        self.cfg.eeagent.heartbeat = 1
        self.factory = Mock()

        self.process_id = "fake"
        self.process = DotDict()
        self.process._process = DotDict()
        self.process._process.heartbeat = Mock(return_value=self.heartbeater_not_ok)

        self.heartbeater = HeartBeater(self.cfg, self.factory, self.process_id, self.process)

    def tearDown(self):
        pass

    def test_heartbeater_waits_for_start(self):

        self.heartbeater.beat = Mock()

        self.heartbeater.poll()
        self.assertFalse(self.heartbeater.beat.called)

        self.process._process.heartbeater = Mock(return_value=self.heartbeater_ok)

        self.heartbeater._started = True

        self.heartbeater.poll()
        self.assertTrue(self.heartbeater.beat.called)