def test_get_specific_watchlist(self, mocker): """ Given: - When: - Calling function list_watchlists_command with alias for specific watchlist Then: - Validate watchlist was returned as expected """ # prepare client = mock_client() args = {'watchlist_alias': TEST_WATCHLIST_ALIAS} mocker.patch.object(client, 'http_request', return_value=MOCKED_WATCHLISTS['value'][0]) with open('TestData/expected_watchlists.json', 'r') as file: expected_watchlist = json.load(file)[0] # run command_result = list_watchlists_command(client=client, args=args) # validate assert '### Watchlists results\n|Name|ID|Description|' in command_result.readable_output assert '| test_watchlist_name_1 | test_watchlist_id_1 | test_description |' in command_result.readable_output assert command_result.raw_response == MOCKED_WATCHLISTS['value'][0] assert expected_watchlist == command_result.outputs[0]
def test_list_watchlist(self, mocker): """ Given: - When: - Calling function list_watchlists_command Then: - Validate watchlist was returned as expected """ # prepare client = mock_client() mocker.patch.object(client, 'http_request', return_value=MOCKED_WATCHLISTS) with open('TestData/expected_watchlists.json', 'r') as file: expected_watchlists = json.load(file) # run command_result = list_watchlists_command(client=client, args={}) # validate assert '### Watchlists results\n|Name|ID|Description|' in command_result.readable_output assert '| test_watchlist_name_1 | test_watchlist_id_1 | test_description |' in command_result.readable_output assert command_result.raw_response == MOCKED_WATCHLISTS assert expected_watchlists == command_result.outputs
def test_user_agent_in_request(self, mocker): """ Given: - Request go to send to Azure When: - Run any command Then: - Validate the required header exist in request """ # prepare client = mock_client() mocker.patch.object(client._client, 'get_access_token') mocker.patch.object(requests.Session, 'request') # run list_watchlists_command(client, args={}) # validate user_agent = requests.Session.request.call_args[1]['headers']['User-Agent'] assert user_agent == XSOAR_USER_AGENT