Пример #1
0
def test_extract_long_description(tmpdir):

    # Test when script
    extractor = Extractor(input=f'{git_path()}/demisto_sdk/tests/test_files/script-test_script.yml',
                          output='', file_type='script', no_demisto_mock=False,
                          no_common_server=False, configuration=Configuration())
    assert extractor.extract_long_description('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_text.txt')), file_type='integration')

    extractor.extract_long_description(extractor.output)
    with open(extractor.output, 'rb') as temp_description:
        assert temp_description.read().decode('utf-8') == 'detaileddescription'
    os.remove(extractor.output)
Пример #2
0
def test_extract_long_description():
    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_long_description('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_long_description(
            f'{git_path()}/demisto_sdk/tests/test_files/temp_file.txt')
        with open(f'{git_path()}/demisto_sdk/tests/test_files/temp_file.txt',
                  'rb') as temp_file:
            file_data = temp_file.read().decode('utf-8')
            assert file_data == 'detaileddescription'
        os.remove(f'{git_path()}/demisto_sdk/tests/test_files/temp_file.txt')
Пример #3
0
def test_extract_long_description():
    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_long_description('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_text.txt'

    extractor.extract_long_description(extractor.output)
    with open(extractor.output, 'rb') as temp_description:
        assert temp_description.read().decode('utf-8') == 'detaileddescription'
    os.remove(extractor.output)