コード例 #1
0
ファイル: test_listen.py プロジェクト: Linaro/squad
    def test_start(self, Popen):
        backend = Backend.objects.create(name="foo")
        manager = ListenerManager()

        manager.start(backend)

        self.assertEqual(Popen.call_args[0][-1][-1], "foo")
コード例 #2
0
ファイル: test_listen.py プロジェクト: yijiangtian/squad
    def test_start(self, Popen):
        backend = Backend.objects.create(name="foo")
        manager = ListenerManager()

        manager.start(backend)

        self.assertEqual(Popen.call_args[0][-1][-1], "foo")
コード例 #3
0
    def test_start(self, Popen):
        backend = Backend.objects.create(name="foo")
        manager = ListenerManager(argv)

        manager.start(backend)

        Popen.assert_called_with(argv + ['foo'])
コード例 #4
0
    def test_stop(self, Listener):
        backend = Backend.objects.create(name="foo")
        manager = ListenerManager()

        manager.start(backend)
        manager.stop(backend.id)

        Listener.return_value.terminate.assert_called_once()
コード例 #5
0
    def test_start(self, Listener):
        backend = Backend.objects.create(name="foo")
        manager = ListenerManager()

        manager.start(backend)

        Listener.assert_called_with(backend)
        instance = Listener.return_value
        instance.start.assert_called_once()
コード例 #6
0
ファイル: test_listen.py プロジェクト: Linaro/squad
    def test_cleanup(self, Popen):
        backend1 = Backend.objects.create(name="foo")
        backend2 = Backend.objects.create(name="bar")
        manager = ListenerManager()
        manager.start(backend1)
        manager.start(backend2)

        manager.stop = MagicMock()

        manager.cleanup()

        manager.stop.assert_has_calls([call(backend1.id), call(backend2.id)], any_order=True)
コード例 #7
0
ファイル: test_listen.py プロジェクト: Linaro/squad
    def test_stop(self, Popen):
        backend = Backend.objects.create(name="foo")
        manager = ListenerManager()

        Popen.return_value.poll.return_value = None

        manager.start(backend)
        manager.stop(backend.id)

        Popen.return_value.poll.assert_called_once()
        Popen.return_value.terminate.assert_called_once()
        Popen.return_value.wait.assert_called_once()
コード例 #8
0
    def test_cleanup(self, Listener):
        backend1 = Backend.objects.create(name="foo")
        backend2 = Backend.objects.create(name="bar")
        manager = ListenerManager()
        manager.start(backend1)
        manager.start(backend2)

        manager.stop = MagicMock()

        manager.cleanup()

        manager.stop.assert_has_calls([call(backend1.id), call(backend2.id)], any_order=True)
コード例 #9
0
ファイル: test_listen.py プロジェクト: yijiangtian/squad
    def test_stop(self, Popen):
        backend = Backend.objects.create(name="foo")
        manager = ListenerManager()

        Popen.return_value.poll.return_value = None

        manager.start(backend)
        manager.stop(backend.id)

        Popen.return_value.poll.assert_called_once()
        Popen.return_value.terminate.assert_called_once()
        Popen.return_value.wait.assert_called_once()
コード例 #10
0
ファイル: test_listen.py プロジェクト: Linaro/squad
    def test_keep_listeners_running_changed(self, Popen):
        manager = ListenerManager()
        backend = Backend.objects.create(name="foo")

        # start existing backends
        manager.keep_listeners_running()

        manager.stop = MagicMock()
        manager.start = MagicMock()

        # backend is changed
        backend.name = 'bar'
        backend.save()
        manager.keep_listeners_running()

        manager.stop.assert_called_with(backend.id)
        manager.start.assert_called_with(backend)
コード例 #11
0
ファイル: test_listen.py プロジェクト: Linaro/squad
    def test_keep_listeners_running_added(self, Popen):
        manager = ListenerManager()
        backend1 = Backend.objects.create(name="foo")

        manager.start = MagicMock()
        manager.stop = MagicMock()

        # start existing backends
        manager.keep_listeners_running()
        manager.start.assert_called_with(backend1)

        # new backend, start it too
        backend2 = Backend.objects.create(name="bar")
        manager.keep_listeners_running()
        manager.start.assert_called_with(backend2)

        manager.stop.assert_not_called()
コード例 #12
0
    def test_keep_listeners_running_changed(self, Listener):
        manager = ListenerManager()
        backend = Backend.objects.create(name="foo")

        # start existing backends
        manager.keep_listeners_running()

        manager.stop = MagicMock()
        manager.start = MagicMock()

        # backend is changed
        backend.name = 'bar'
        backend.save()
        manager.keep_listeners_running()

        manager.stop.assert_called_with(backend.id)
        manager.start.assert_called_with(backend)
コード例 #13
0
    def test_keep_listeners_running_added(self, Listener):
        manager = ListenerManager()
        backend1 = Backend.objects.create(name="foo")

        manager.start = MagicMock()
        manager.stop = MagicMock()

        # start existing backends
        manager.keep_listeners_running()
        manager.start.assert_called_with(backend1)

        # new backend, start it too
        backend2 = Backend.objects.create(name="bar")
        manager.keep_listeners_running()
        manager.start.assert_called_with(backend2)

        manager.stop.assert_not_called()
コード例 #14
0
    def test_keep_listeners_running_restart_dead_process(self, Popen):
        manager = ListenerManager()
        backend = Backend.objects.create(name="foo")

        # start existing backends
        manager.keep_listeners_running()

        self.assertEqual(1, len(manager.__processes__))
        Popen.assert_called()

        # "kill" the process
        Popen.return_value.poll.return_value = -15  # SIGKILL
        manager.stop = MagicMock()
        manager.start = MagicMock()

        # Give it another go
        manager.keep_listeners_running()

        manager.stop.assert_called_with(backend.id)
        manager.start.assert_called_with(backend)