def test_get_console_output_raises_item_not_found_error_if_console_output_file_doesnt_exist(self):
        self.os_path_isfile_mock = self.patch('app.common.cluster_service.os.path.isfile')
        self.os_path_isfile_mock.return_value = False
        service = ClusterService()

        with self.assertRaises(ItemNotFoundError):
            service.get_console_output(1, 2, 3, os.path.abspath('~'))
示例#2
0
    def test_get_console_output_happy_path_returns_return_values(self):
        segment = ConsoleOutputSegment(offset_line=0, num_lines=1, total_num_lines=2, content='The content\n')
        self.patch('app.common.cluster_service.BuildArtifact').get_console_output.return_value = segment
        service = ClusterService()

        response = service.get_console_output(1, 2, 3, os.path.abspath('~'))

        self.assertDictEqual(
            response,
            {
                'offset_line': 0,
                'num_lines': 1,
                'total_num_lines': 2,
                'content': 'The content\n',
            },
            'The response dictionary did not contain the expected contents.'
        )
    def test_get_console_output_happy_path_returns_return_values(self):
        self.os_path_isfile_mock = self.patch('app.common.cluster_service.os.path.isfile')
        self.os_path_isfile_mock.return_value = True
        console_output_patch = self.patch('app.common.cluster_service.ConsoleOutput').return_value
        console_output_patch.segment.return_value = ConsoleOutputSegment(
            offset_line=0, num_lines=1, total_num_lines=2, content='The content\n')
        service = ClusterService()

        response = service.get_console_output(1, 2, 3, os.path.abspath('~'))

        self.assertDictEqual(
            response,
            {
                'offset_line': 0,
                'num_lines': 1,
                'total_num_lines': 2,
                'content': 'The content\n',
            },
            'The response dictionary did not contain the expected contents.'
        )
    def test_get_console_output_raises_bad_request_error_with_invalid_arguments(self, max_lines, offset_line):
        service = ClusterService()

        with self.assertRaises(BadRequestError):
            service.get_console_output(1, 2, 3, os.path.abspath('~'), max_lines=max_lines, offset_line=offset_line)
示例#5
0
    def test_get_console_output_raises_item_not_found_error_if_console_output_file_doesnt_exist(self):
        self.patch('app.common.cluster_service.BuildArtifact').get_console_output.return_value = None
        service = ClusterService()

        with self.assertRaises(ItemNotFoundError):
            service.get_console_output(1, 2, 3, os.path.abspath('~'))