def test_search_pack_with_failure(mocker):
    """
   Given
   - Error when searching for pack
   - Response with missing data
   When
   - Searching the pack in the Demsito instance for installation.
   Then
   - Ensure error is raised.
   """
    client = MockClient()
    prints_manager = ParallelPrintsManager(1)
    lock = MockLock()

    # Error when searching for pack
    mocker.patch.object(demisto_client,
                        'generic_request_func',
                        return_value=('', 500, None))
    script.search_pack(client, prints_manager, "New Hello World", 'HelloWorld',
                       0, lock)
    assert not script.SUCCESS_FLAG

    # Response with missing data
    mocker.patch.object(demisto_client,
                        'generic_request_func',
                        return_value=('{"id": "HelloWorld"}', 200, None))
    script.search_pack(client, prints_manager, "New Hello World", 'HelloWorld',
                       0, lock)
    assert not script.SUCCESS_FLAG
예제 #2
0
def test_search_pack_with_id(mocker):
    """
   Given
   - Pack with a new name (different from its ID)
   When
   - Searching the pack in the Demsito instance.
   Then
   - Ensure the pack is found using its ID
   """
    client = MockClient()
    mocker.patch.object(demisto_client, 'generic_request_func', side_effect=mocked_generic_request_func)
    expected_response = {
        'id': 'HelloWorld',
        'version': '1.1.10'
    }
    assert expected_response == script.search_pack(client, "New Hello World", 'HelloWorld', None)