def test_get_remote_data_when_dont_need_update(mocker): """ Given: - Information regarding a changed incident in Demisto When: - Running get-remote-date and the incident was already updated Then: - There aren't change to perform in Demisto """ from JiraV2 import get_remote_data_command from test_data.expected_results import GET_JIRA_ISSUE_RES updated_date = "1996-11-25T16:29:37.277764067Z" GET_JIRA_ISSUE_RES["updated"] = updated_date mocker.patch.object(demisto, "info") mocker.patch.object(demisto, "debug") mocker.patch("JiraV2.get_issue", return_value=("", "", GET_JIRA_ISSUE_RES)) mocker.patch( "JiraV2.get_comments_command", return_value=("No comments were found in the ticket", None, None), ) mocker.patch("JiraV2.get_attachments", return_value="") res = get_remote_data_command( {"id": "15", "lastUpdate": "2050-11-25T16:29:37.277764067Z"} ) assert res.mirrored_object == {'in_mirror_error': ''} assert res.entries == []
def test_get_remote_data_when_needs_update(mocker): """ Given: - Information regarding a changed incident in Demisto When: - Running get-remote-date and the incident needs to be updated Then: - Returns GetRemoteDataResponse object with the incident's details that needs to be updated """ from JiraV2 import get_remote_data_command from test_data.expected_results import GET_JIRA_ISSUE_RES mocker.patch.object(demisto, "info") mocker.patch.object(demisto, "debug") mocker.patch("JiraV2.get_issue", return_value=("", "", GET_JIRA_ISSUE_RES)) mocker.patch( "JiraV2.get_comments_command", return_value=("No comments were found in the ticket", None, None), ) mocker.patch("JiraV2.get_attachments", return_value="") res = get_remote_data_command({"id": "15", "lastUpdate": "0"}) assert len(res.mirrored_object) != 0 assert res.entries == []
def test_get_remote_data(mocker): """ Given: - Jira v2 client - An update for the issue When: - Running get-remote-date Then: - Verify the `updated` field is set as expected """ from JiraV2 import get_remote_data_command updated_date = '2020-11-25T16:29:37.277764067Z' mocker.patch( 'JiraV2.get_issue', return_value=('', '', {'fields': {'updated': updated_date}}) ) res = get_remote_data_command('id', '0') assert res.mirrored_object['updated'] == updated_date