Esempio n. 1
0
def test_get_new_attachment_without_return_new_attachment(mocker):
    """
    Given:
        - attachment related to an issue
        - The date the incident was last updated

    When:
        - An incident's attachment wasn't modified

    Then:
        - There is no attachment to update
    """
    from JiraV2 import get_attachments
    from test_data.expected_results import JIRA_ATTACHMENT
    from dateparser import parse
    import pytz

    class file:
        def __init__(self):
            self.content = b"content"

    file_content = file()
    mocker.patch("JiraV2.jira_req", return_value=file_content)
    res = get_attachments(
        JIRA_ATTACHMENT,
        parse("2070-11-25T16:29:37.277764067Z").replace(tzinfo=pytz.UTC),
    )
    assert res == []
Esempio n. 2
0
def test_get_all_attachment_return_result(requests_mock):
    """
    Given:
        - attachment related to an issue
        - The date the incident was last updated

    When:
        - An incident's attachment was modified\added

    Then:
        - Getting all attachments as fileResult
    """
    from JiraV2 import get_attachments
    from test_data.expected_results import JIRA_ATTACHMENT_ALL
    from dateparser import parse

    for attachment in JIRA_ATTACHMENT_ALL:
        requests_mock.get(attachment.get('content'), json={})
        requests_mock.get(attachment.get('self'),
                          json={'filename': attachment.get('filename')})

    res = get_attachments(JIRA_ATTACHMENT_ALL,
                          parse("1996-11-25T16:29:35.277764067Z"),
                          only_new=False)
    assert res[0]["File"] == "filename1"
    assert res[1]["File"] == "filename2"
    assert res[2]["File"] == "filename3"
Esempio n. 3
0
def test_get_all_attachment_return_result(mocker):
    """
    Given:
        - attachment related to an issue
        - The date the incident was last updated

    When:
        - An incident's attachment was modified\added

    Then:
        - Getting all attachments as fileResult
    """
    from JiraV2 import get_attachments
    from test_data.expected_results import JIRA_ATTACHMENT_ALL
    from dateparser import parse

    class file:
        def __init__(self):
            self.content = b"content"

    file_content = file()
    mocker.patch("JiraV2.jira_req", return_value=file_content)
    res = get_attachments(
        JIRA_ATTACHMENT_ALL, parse("1996-11-25T16:29:35.277764067Z"), only_new=False
    )
    assert res[0]["File"] == "download.png"
    assert res[1]["File"] == "download1.png"
    assert res[2]["File"] == "download2.png"
Esempio n. 4
0
def test_get_new_attachment_return_result(requests_mock):
    """
    Given:
        - attachment related to an issue
        - The date the incident was last updated

    When:
        - An incident's attachment was modified\added

    Then:
        - The updated\new as fileResult
    """
    from JiraV2 import get_attachments
    from test_data.expected_results import JIRA_ATTACHMENT
    from dateparser import parse

    requests_mock.get('https://localhost/rest/attachment/content/14848',
                      json={})
    res = get_attachments(JIRA_ATTACHMENT,
                          parse("1996-11-25T16:29:35.277764067Z"))
    assert res[0]["File"] == "download.png"