forked from python-bugzilla/python-bugzilla
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: Add full Bugzilla attach API coverage
Signed-off-by: Cole Robinson <crobinso@redhat.com>
- Loading branch information
Showing
7 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{'content_type': 'text/plain', | ||
'file_name': 'bz-attach-get1.txt', | ||
'ids': [123456], | ||
'is_private': True, | ||
'summary': 'some desc'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{'exclude_fields': ['bar'], 'include_fields': ['foo']} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{'flags': [{'is_patch': True, 'name': 'needinfo', 'value': 'foobar'}], | ||
'ids': [112233]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# This work is licensed under the GNU GPLv2 or later. | ||
# See the COPYING file in the top-level directory. | ||
# | ||
|
||
import os | ||
|
||
import pytest | ||
|
||
import tests | ||
import tests.mockbackend | ||
|
||
|
||
def test_api_attachments(): | ||
# misc coverage testing for Bugzilla attachment APIs | ||
fakebz = tests.mockbackend.make_bz( | ||
bug_attachment_get_all_args=( | ||
"data/mockargs/test_attachments_getall1.txt"), | ||
bug_attachment_get_all_return={}, | ||
bug_attachment_update_args=( | ||
"data/mockargs/test_attachments_update1.txt"), | ||
bug_attachment_update_return={}, | ||
bug_attachment_get_args=( | ||
"data/mockargs/test_attachments_get1.txt"), | ||
bug_attachment_get_return=( | ||
"data/mockreturn/test_attach_get1.txt"), | ||
bug_attachment_create_args=( | ||
"data/mockargs/test_api_attachments_create1.txt"), | ||
bug_attachment_create_return={ | ||
"attachments": {"123456": {}, "456789": []}}, | ||
) | ||
|
||
# coverage for include/exclude handling | ||
fakebz.get_attachments([123456], None, | ||
include_fields=["foo"], exclude_fields="bar") | ||
|
||
# coverage for updateattachment | ||
fakebz.updateattachmentflags(None, "112233", "needinfo", | ||
value="foobar", is_patch=True) | ||
|
||
# coverage for openattachment | ||
fobj = fakebz.openattachment(502352) | ||
assert "Hooray" in str(fobj.read()) | ||
|
||
# Error on bad input type | ||
with pytest.raises(TypeError): | ||
fakebz.attachfile([123456], None, "some desc") | ||
|
||
# Misc attachfile() pieces | ||
attachfile = os.path.dirname(__file__) + "/data/bz-attach-get1.txt" | ||
ret = fakebz.attachfile([123456], attachfile, "some desc", | ||
isprivate=True) | ||
assert ret == [123456, 456789] |