def test_polling(self):
        """ Assert polling is setup upon start and cleaned up upon stop
        """
        manager = DeploymentManager()

        manager._poll_interval = 1
        rest_manager = MagicMock()
        rest_manager.add_web_handler = MagicMock()
        manager._rest_manager = rest_manager

        self.assertIsNone(manager._poll_job)
        manager.start()
        self.assertIsNotNone(manager._poll_job)
        manager.stop()
        self.assertIsNone(manager._poll_job)
    def test_start_stop(self):
        # Test a handler is created and passed to REST Manager on start

        rest_manager = MagicMock()
        rest_manager.add_web_handler = MagicMock()
        context = CoreContext([], [])

        manager = DeploymentManager()
        manager.get_dependency = MagicMock(return_value=rest_manager)

        with patch("nio.modules.settings.Settings.get"):
            manager.configure(context)

        manager.start()
        rest_manager.add_web_handler.\
            assert_called_with(manager._config_handler)
        self.assertEqual(2, len(rest_manager.add_web_handler.call_args))
        self.assertTrue(
            isinstance(rest_manager.add_web_handler.call_args[0][0],
                       RESTHandler))
        manager.stop()
        rest_manager.remove_web_handler.\
            assert_called_with(manager._config_handler)