def test_docker_cli_remove_container_not_found(self): remove_container = self.mock_client.return_value.remove_container remove_container.side_effect = errors.NotFound('Not Found') docker = DockerCli() docker.filtered_statuses = (self.container['State'], ) self.assertRaises(NotFoundContainerException, docker.remove_container, 'id123')
def testWaitUntilRunning_FailIfContainerNotFound(self, mock_time): # Prepare mocks and variables. container = self._docker_client.containers.run.return_value container.reload.side_effect = docker_errors.NotFound('message required.') runner = self._CreateLocalDockerRunner() mock_time.side_effect = list(range(20)) # Setup state. runner.Start() # Act. with self.assertRaises(error_types.JobAborted): runner.WaitUntilRunning(deadline=10)
def get(self, stack_name): """ Get a stack by name. Args: stack_name (str): Stack name. Returns: A :py:class:`Stack` object. Raises: :py:class:`docker.errors.NotFound` If the stack does not exist. """ stacks = self.list() stack = next((x for x in stacks if x.name == stack_name), None) if stack is None: raise errors.NotFound('stack {} not found'.format(stack_name)) return stack