def test_process_readme_doc_playbookl(tmp_path, mocker): mocker.patch('gendocs.get_packname_from_metadata', return_value=('', False)) res = process_readme_doc( str(tmp_path), SAMPLE_CONTENT, 'integrations', str(tmp_path), "dummy-relative", f'{SAMPLE_CONTENT}/Playbooks/playbook-lost_stolen_device_README.md') assert res.name == 'Lost / Stolen Device Playbook' assert 'Initial incident details should be the name of the reporting person' in res.description
def test_process_readme_doc_edl(tmp_path, mocker): mocker.patch('gendocs.get_packname_from_metadata', return_value=('', False)) res = process_readme_doc( str(tmp_path), SAMPLE_CONTENT, 'integrations', str(tmp_path), "dummy-relative", f'{SAMPLE_CONTENT}/Integrations/PaloAltoNetworks_PAN_OS_EDL_Management/README.md' ) assert res.name == 'Palo Alto Networks PAN-OS EDL Management'
def test_process_readme_doc_same_dir(tmp_path): res = process_readme_doc(str(tmp_path), SAMPLE_CONTENT, f'{SAMPLE_CONTENT}/Integrations/integration-F5_README.md', ) assert res.id == 'f5-firewall' assert res.description assert res.name == 'F5 firewall' with open(str(tmp_path / f'{res.id}.md'), 'r') as f: assert f.readline().startswith('---') assert f.readline().startswith(f'id: {res.id}') assert f.readline().startswith(f'title: "{res.name}"') assert f.readline().startswith(f'custom_edit_url: https://github.com/demisto/content/')
def test_process_code_script(tmp_path): res = process_readme_doc(str(tmp_path), SAMPLE_CONTENT, f'{SAMPLE_CONTENT}/Scripts/script-IsIPInRanges_README.md') assert res.id == 'is-ip-in-ranges' assert res.description assert res.name == 'IsIPInRanges' with open(str(tmp_path / f'{res.id}.md'), 'r') as f: assert f.readline().startswith('---') assert f.readline().startswith(f'id: {res.id}') assert f.readline().startswith(f'title: "{res.name}"') assert f.readline().startswith(f'custom_edit_url: https://github.com/demisto/content/')
def test_process_readme_doc(tmp_path, mocker): mocker.patch('gendocs.get_packname_from_metadata', return_value=('', False)) res = process_readme_doc( str(tmp_path), SAMPLE_CONTENT, 'integrations', str(tmp_path), "dummy-relative", f'{SAMPLE_CONTENT}/Integrations/DomainTools_Iris/README.md') assert res.id == 'domain-tools-iris' assert res.description assert res.name == 'DomainTools Iris' with open(str(tmp_path / f'{res.id}.md'), 'r') as f: assert f.readline().startswith('---') assert f.readline().startswith(f'id: {res.id}') assert f.readline().startswith(f'title: "{res.name}"') assert f.readline().startswith( 'custom_edit_url: https://github.com/demisto/content/') content = f.read() assert 'dummy-relative' not in content res = process_readme_doc(str(tmp_path), BASE_DIR, 'integrations', str(tmp_path), "dummy-relative", f'{BASE_DIR}/test_data/empty-readme.md') assert 'no yml file found' in res.error_msg process_readme_doc( str(tmp_path), SAMPLE_CONTENT, 'integrations', str(tmp_path), "dummy-relative", f'{SAMPLE_CONTENT}/Integrations/SlashNextPhishingIncidentResponse/README.md' ) process_readme_doc(str(tmp_path), SAMPLE_CONTENT, 'integrations', str(tmp_path), "dummy-relative", f'{SAMPLE_CONTENT}/Integrations/Gmail/README.md')
def test_process_code_script(tmp_path, mocker): mocker.patch('gendocs.get_packname_from_metadata', return_value=('', False)) res = process_readme_doc( str(tmp_path), SAMPLE_CONTENT, 'integrations', str(tmp_path), "dummy-relative", f'{SAMPLE_CONTENT}/Scripts/script-IsIPInRanges_README.md') assert res.id == 'is-ip-in-ranges' assert res.description assert res.name == 'IsIPInRanges' with open(str(tmp_path / f'{res.id}.md'), 'r') as f: assert f.readline().startswith('---') assert f.readline().startswith(f'id: {res.id}') assert f.readline().startswith(f'title: "{res.name}"') assert f.readline().startswith( 'custom_edit_url: https://github.com/demisto/content/') content = f.read() assert 'dummy-relative' not in content
def test_process_readme_doc(tmp_path): res = process_readme_doc(str(tmp_path), SAMPLE_CONTENT, f'{SAMPLE_CONTENT}/Integrations/DomainTools_Iris/README.md') assert res.id == 'domain-tools-iris' assert res.description assert res.name == 'DomainTools Iris' with open(str(tmp_path / f'{res.id}.md'), 'r') as f: assert f.readline().startswith('---') assert f.readline().startswith(f'id: {res.id}') assert f.readline().startswith(f'title: "{res.name}"') assert f.readline().startswith(f'custom_edit_url: https://github.com/demisto/content/') res = process_readme_doc(str(tmp_path), BASE_DIR, f'{BASE_DIR}/test_data/empty-readme.md') assert 'no yml file found' in res.error_msg process_readme_doc(str(tmp_path), SAMPLE_CONTENT, f'{SAMPLE_CONTENT}/Integrations/SlashNextPhishingIncidentResponse/README.md') process_readme_doc(str(tmp_path), SAMPLE_CONTENT, f'{SAMPLE_CONTENT}/Integrations/Gmail/README.md')
def test_process_readme_doc_playbookl(tmp_path): res = process_readme_doc( str(tmp_path), SAMPLE_CONTENT, f'{SAMPLE_CONTENT}/Playbooks/playbook-lost_stolen_device_README.md') assert res.name == 'Lost / Stolen Device Playbook' assert 'Initial incident details should be the name of the reporting person' in res.description
def test_process_readme_doc_edl(tmp_path): res = process_readme_doc( str(tmp_path), SAMPLE_CONTENT, f'{SAMPLE_CONTENT}/Integrations/PaloAltoNetworks_PAN_OS_EDL_Management/README.md' ) assert res.name == 'Palo Alto Networks PAN-OS EDL Management'