def test_cyren_feed_relationship_no_indicator(): """ Given: no indicator When: Running cyren_feed_relationship command. Then: ValueError is raised """ from CyrenThreatInDepthRelatedWidget import cyren_feed_relationship with pytest.raises(ValueError): cyren_feed_relationship({})
def test_cyren_feed_relationship_no_indicator(mocker): """ Given: Empty args When: Running cyren_feed_relationship command. Then: An exception is raised """ from CyrenThreatInDepthRelatedWidget import cyren_feed_relationship mocker.patch.object(demisto, "executeCommand", side_effect=executeCommand()) with pytest.raises(ValueError): cyren_feed_relationship(dict())
def test_cyren_feed_relationship_error_response(mocker): """ Given: An error in the inner script When: Running cyren_feed_relationship command. Then: An exception is raised """ from CyrenThreatInDepthRelatedWidget import cyren_feed_relationship mocker.patch.object(demisto, "executeCommand", side_effect=executeCommand(error=True)) args = dict(indicator=dict(some="value")) with pytest.raises(ValueError): cyren_feed_relationship(args)
def test_cyren_feed_relationship_normal(mocker): """ Given: Normal arg input When: Running cyren_feed_relationship command. Then: The output is redirected from the inner script and default columns are used """ from CyrenThreatInDepthRelatedWidget import cyren_feed_relationship mocker.patch.object(demisto, "executeCommand", side_effect=executeCommand()) args = dict(indicator=dict(some="value")) result = cyren_feed_relationship(args) demisto.executeCommand.assert_any_call( "CyrenThreatInDepthRenderRelated", dict(indicator="{\"some\": \"value\"}")) assert result.readable_output == "tha output!"
def test_cyren_feed_relationship_without_search_response(mocker): """ Given: File hash indicator. When: Running cyren_feed_relationship command. Then: Verify expected results returns """ from CyrenThreatInDepthRelatedWidget import cyren_feed_relationship args = {"indicator": FILE_INDICATOR} mocker.patch.object(demisto, "searchIndicators", return_value=SEARCH_INDICATORS_EMPTY_RESPONSE) result = cyren_feed_relationship(args) assert result.readable_output == ( "|Indicator Type|Value|Reputation|Relationship Type|Entity Category|Timestamp UTC|\n" "|---|---|---|---|---|---|\n" "| SHA-256 | 0f6dbfb291ba1b84601b0372f70db3430df636c631d074c1c2463f9e5a033f21<br> | " "None (0) | downloaded from | malware | 2020-10-28, 14:45:24 |\n")