Exemple #1
0
 def test_get_custom_content_objects(self, tmp_path):
     env = Environment(tmp_path)
     with patch.object(Downloader, "__init__", lambda a, b, c: None):
         downloader = Downloader('', '')
         downloader.custom_content_temp_dir = env.CUSTOM_CONTENT_BASE_PATH
         custom_content_objects = downloader.get_custom_content_objects()
         assert ordered(custom_content_objects) == ordered(
             env.CUSTOM_CONTENT)
 def test_handle_all_custom_content_flag(self):
     with patch.object(Downloader, "__init__", lambda a, b, c: None):
         downloader = Downloader('', '')
         downloader.custom_content_temp_dir = CUSTOM_CONTENT_BASE_PATH
         downloader.all_custom_content = True
         downloader.handle_all_custom_content_flag()
         custom_content_names = [cco['name'] for cco in CUSTOM_CONTENT]
         assert ordered(custom_content_names) == ordered(downloader.input_files)
 def test_handle_list_files_flag(self, capsys):
     with patch.object(Downloader, "__init__", lambda a, b, c: None):
         downloader = Downloader('', '')
         downloader.custom_content_temp_dir = CUSTOM_CONTENT_BASE_PATH
         downloader.list_files = True
         answer = downloader.handle_list_files_flag()
         stdout, _ = capsys.readouterr()
         list_files = [[cco['name'], cco['entity'][:-1]] for cco in CUSTOM_CONTENT]
         for file in list_files:
             assert file[0] in stdout
             assert file[1] in stdout
         assert answer
 def test_handle_list_files_flag_error(self, mocker):
     """
     GIVEN a file contained in custom content of not supported type
     WHEN the user runs demisto-sdk download -lf
     THEN the handle_list_files_flag method should ignore the file
     """
     mocker.patch('demisto_sdk.commands.download.downloader.get_dict_from_file', return_value=({}, 'json'))
     mocker.patch('demisto_sdk.commands.download.downloader.get_child_files', return_value=['path'])
     with patch.object(Downloader, "__init__", lambda a, b, c: None):
         downloader = Downloader('', '')
         downloader.custom_content_temp_dir = INTEGRATION_INSTANCE_PATH
         downloader.list_files = True
         assert downloader.handle_list_files_flag()
 def test_get_custom_content_objects(self):
     with patch.object(Downloader, "__init__", lambda a, b, c: None):
         downloader = Downloader('', '')
         downloader.custom_content_temp_dir = CUSTOM_CONTENT_BASE_PATH
         custom_content_objects = downloader.get_custom_content_objects()
         assert ordered(custom_content_objects) == ordered(CUSTOM_CONTENT)