import pytest import Intel471Malware as feed BUILD_PARAM_DICT_DATA = [ ( { "credentials": {"identifier": "username", "password": "apikey"}, "insecure": True, "search_indicator_type": "ipv4", "confidence": "high", "auto_detect_type": False, "proxy": True, }, # input {"confidence": "high"}, # expected ), ( { "credentials": {"identifier": "username", "password": "apikey"}, "insecure": True, "auto_detect_type": False, "proxy": True, }, # input {}, # expected ), ( { "credentials": {"identifier": "username", "password": "apikey"}, "insecure": True, "search_indicator_type": "ipv4", "threat_type": "malware", "confidence": "high", "auto_detect_type": False, "proxy": True, }, # input {"confidence": "high", "threatType": "malware"}, # expected ), ] @pytest.mark.parametrize("input,expected_results", BUILD_PARAM_DICT_DATA) def test_build_url_parameter_dict(mocker, input, expected_results): """ Given: - set of parameters from demisto. When: - create an instance and on every run. Then: - Returns a dictionary of relevant params only. """ params_dict = feed._build_url_parameter_dict(**input) assert params_dict == expected_results BUILD_URL_DATA = [ ( {"confidence": "high", "indicatorType": "ipv4"}, # input "https://api.intel471.com/v1/indicators/stream?confidence=high&indicatorType=ipv4", # expected ), ( {}, # input "https://api.intel471.com/v1/indicators/stream?", # expected ), ] @pytest.mark.parametrize("input,expected_results", BUILD_URL_DATA) def test_create_url(mocker, input, expected_results): """ Given: - set of parameters from demisto. When: - create an instance and on every run. Then: - Returns a url for a get request. """ url = feed._create_url(**input) assert url == expected_results