Esempio n. 1
0
    def setUp(self):
        """
        Run before each test
        """
        #  Only patch if this is a unit test. Otherwise create dummy mock so
        #  code that affects the mock can run.
        self.subprocess_mock = MagicMock(return_value='')
        if not os.environ.get('MAGMA_INTEGRATION_TEST'):
            subprocess.check_output = self.subprocess_mock

        #  Ensure test process is stopped
        self.dummy_service = ServiceManager.ServiceControl(
            name='dummy_service',
            init_system_spec=ServiceManager.SystemdInitSystem)
        self.dummy_service.stop_process()
Esempio n. 2
0
    def setUp(self):
        """
        Run before each test
        """
        self.is_integration_test = bool(
            os.environ.get('MAGMA_INTEGRATION_TEST'), )
        #  Only patch if this is a unit test. Otherwise create dummy mock so
        #  code that affects the mock can run.
        self.subprocess_mock = MagicMock(return_value='')
        if not self.is_integration_test:
            subprocess.check_output = self.subprocess_mock

        if not self.is_integration_test:
            self.dummy_service = ServiceManager.ServiceControl(
                name='dummy_service',
                init_system_spec=ServiceManager.RunitInitSystem,
            )
            self.dummy_service.stop_process()
    def setUp(self):
        """
        Run before each test
        """
        self._loop = asyncio.new_event_loop()
        asyncio.set_event_loop(self._loop)
        #  Only patch if this is a unit test. Otherwise create dummy mock so
        #  code that affects the mock can run.
        self.subprocess_mock = MagicMock(return_value='')
        if not os.environ.get('MAGMA_INTEGRATION_TEST'):
            subprocess.check_output = self.subprocess_mock

        #  Ensure test process is stopped
        self.dummy_service = ServiceManager.ServiceControl(
            name='dummy_service',
            init_system_spec=ServiceManager.DockerInitSystem)
        try:
            self._loop.run_until_complete(self.dummy_service.stop_process())
        except FileNotFoundError:
            pass