def test_find_known_words_from_pack_ignore_commands_name(repo): """ Given: - Pack's structure is correct and pack-ignore file is present. When: - Running DocReviewer.find_known_words_from_pack. Then: - Ensure the found path result is appropriate. - Ensure the commands names are ignored. """ pack = repo.create_pack('test_pack') pack_integration_path = os.path.join( AZURE_FEED_PACK_PATH, "Integrations/FeedAzure/FeedAzure.yml") valid_integration_yml = get_yaml(pack_integration_path, cache_clear=True) pack.create_integration(name="first_integration", yml=valid_integration_yml) rn_file = pack.create_release_notes( version='1_0_0', content='azure-hidden-command \n azure-get-indicators') doc_reviewer = DocReviewer(file_paths=[]) with ChangeCWD(repo.path): found_known_words = doc_reviewer.find_known_words_from_pack( rn_file.path)[1] assert 'azure-hidden-command' in found_known_words assert 'azure-get-indicators' in found_known_words
def test_find_known_words_from_pack(repo, known_words_content, expected_known_words): """ Given: - Pack's structure is correct and pack-ignore file is present. - Case A: pack-ignore file has known_words section with words. - Case B: pack-ignore file has known_words section without words. - Case C: pack-ignore file doesn't have a known_words section. When: - Running DocReviewer.find_known_words_from_pack. Then: - Ensure the found path result is appropriate. - Ensure the pack name (test_pack) is in the know words. """ pack = repo.create_pack('test_pack') rn_file = pack.create_release_notes(version='1_0_0', content='Some release note') pack.pack_ignore.write_list(known_words_content) doc_reviewer = DocReviewer(file_paths=[]) with ChangeCWD(repo.path): assert doc_reviewer.find_known_words_from_pack( rn_file.path) == ('Packs/test_pack/.pack-ignore', expected_known_words)
def test_find_known_words_from_pack_ignore_integrations_name(repo): """ Given: - Pack's structure is correct and pack-ignore file is present. When: - Running DocReviewer.find_known_words_from_pack. Then: - Ensure the found path result is appropriate. - Ensure the integrations name are ignored. """ pack = repo.create_pack('test_pack') integration1 = pack.create_integration(name="first_integration") integration2 = pack.create_integration(name="second_integration") rn_file = pack.create_release_notes( version='1_0_0', content=f'{integration1.name}\n{integration2.name}') doc_reviewer = DocReviewer(file_paths=[]) with ChangeCWD(repo.path): found_known_words = doc_reviewer.find_known_words_from_pack( rn_file.path)[1] assert integration1.name in found_known_words assert integration2.name in found_known_words
def test_find_known_words_from_pack_ignore_commons_scripts_name(repo): """ Given: - Pack's structure is correct and pack-ignore file is present. - The scripts are in the old version (JS code), no Scripts' dir exists (only yml amd md files). When: - Running DocReviewer.find_known_words_from_pack. Then: - Ensure the found path result is appropriate. - Ensure the scripts names are ignored. - Ensure script readme name is not handled (bla.md) """ pack = repo.create_pack('test_pack') script1_name = 'script-first_script' # add a yml script directly into Scripts folder pack._create_yaml_based(name=script1_name, dir_path=f'{pack.path}//Scripts', content={'name': script1_name}) # add a .md file script directly into Scripts folder pack._create_text_based('bla.md', '', dir_path=Path(f'{pack.path}//Scripts')) # add a script into second_script folder script2 = pack.create_script(name='second_script') rn_file = pack.create_release_notes( version='1_0_0', content=f'{script1_name}\n{script2.name}') doc_reviewer = DocReviewer(file_paths=[]) with ChangeCWD(repo.path): found_known_words = doc_reviewer.find_known_words_from_pack( rn_file.path)[1] assert script1_name in found_known_words assert script2.name in found_known_words assert 'bla.md' not in found_known_words