def test_extract_image(tmpdir): # Test when script extractor = Extractor(input=f'{git_path()}/demisto_sdk/tests/test_files/script-test_script.yml', output='', file_type='script') assert extractor.extract_image('output_path') == 0 # Test opening the file and writing to it extractor = Extractor(input=f'{git_path()}/demisto_sdk/tests/test_files/integration-Zoom.yml', output=str(tmpdir.join('temp_image.png')), file_type='integration') extractor.extract_image(extractor.output) with open(extractor.output, 'rb') as temp_image: image_data = temp_image.read() image = base64.b64encode(image_data).decode('utf-8') assert image == DEFAULT_IMAGE_BASE64
def test_extract_image(): from demisto_sdk.commands.split_yml.extractor import Extractor configuration = Configuration() with patch.object(Extractor, '__init__', lambda a, b, c, d, e, f, g: None): # Test yml_type is script extractor = Extractor('', '', False, False, '', configuration) extractor.yml_type = '' extractor.yml_path = 'script' assert extractor.extract_image('output_path') == 0 # Test opening the file and writing to it extractor.yml_path = f'{git_path()}/demisto_sdk/tests/test_files/integration-Zoom.yml' extractor.extract_image( f'{git_path()}/demisto_sdk/tests/test_files/temp_image.png') with open(f'{git_path()}/demisto_sdk/tests/test_files/temp_image.png', 'rb') as temp_image: image_data = temp_image.read() image = base64.b64encode(image_data).decode('utf-8') assert image == DEFAULT_IMAGE_BASE64 os.remove(f'{git_path()}/demisto_sdk/tests/test_files/temp_image.png')
def test_extract_image(): from demisto_sdk.commands.split_yml.extractor import Extractor # Test when script extractor = Extractor(input='script', output='', file_type='script', no_demisto_mock=False, no_common_server=False, configuration=Configuration()) assert extractor.extract_image('output_path') == 0 # Test opening the file and writing to it extractor.input = f'{git_path()}/demisto_sdk/tests/test_files/integration-Zoom.yml' extractor.file_type = 'integration' extractor.output = f'{git_path()}/demisto_sdk/tests/test_files/temp_image.png' extractor.extract_image(extractor.output) with open(extractor.output, 'rb') as temp_image: image_data = temp_image.read() image = base64.b64encode(image_data).decode('utf-8') assert image == DEFAULT_IMAGE_BASE64 os.remove(extractor.output)