Skip to content

Use proper REST API route for getting a single bug (fixes #174) - #183

Merged
crobinso merged 2 commits into
python-bugzilla:mainfrom
crazyscientist:174-get-single-bug
Oct 24, 2023
Merged

crobinso merged 2 commits into
python-bugzilla:mainfrom
crazyscientist:174-get-single-bug

Conversation

@crazyscientist

@crazyscientist crazyscientist commented Sep 8, 2023

Copy link
Copy Markdown
Contributor

This avoids an IndexError in Bugzilla._getbugand ensures that aBugzillaError` gets raised e.g. if the bug ID does not exist or the client is not authorized.

closes #174

…illa#174)

This avoids an `IndexError` in Bugzilla._getbug` and ensures that a `BugzillaError` gets raised
e.g. if the bug ID does not exist or the client is not authorized.
@codecov

codecov Bot commented Sep 8, 2023

Copy link
Copy Markdown

Codecov Report

Patch and project coverage have no change.

Comparison is base (9363b2d) 100.00% compared to head (ea43eae) 100.00%.
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #183   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           12        12           
  Lines         2195      2195           
=========================================
  Hits          2195      2195           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@crazyscientist

Copy link
Copy Markdown
Contributor Author
pytest --ro-functional --rw-functional
...
================================================= short test summary info =================================================
FAILED tests/test_rw_functional.py::test04NewBugAllFields[XMLRPC] - assert [] == [461686, 461687]
FAILED tests/test_rw_functional.py::test05ModifyStatus[XMLRPC] - RuntimeError: Command failed with 3
FAILED tests/test_rw_functional.py::test06ModifyEmails[XMLRPC] - xmlrpc.client.Fault: <Fault 32000: 'You do not have permission to remove other people from the CC list.'>
FAILED tests/test_rw_functional.py::test07ModifyMultiFlags[XMLRPC] - RuntimeError: Command failed with 3
FAILED tests/test_rw_functional.py::test07ModifyMisc[XMLRPC] - RuntimeError: Command failed with 3
FAILED tests/test_rw_functional.py::test09Whiteboards[XMLRPC] - RuntimeError: Command failed with 3
FAILED tests/test_rw_functional.py::test13SubComponents[XMLRPC] - xmlrpc.client.Fault: <Fault 102: 'You are not authorized to access bug #185526. Most likely the bug has been restricte...
FAILED tests/test_rw_functional.py::test14ExternalTrackersAddUpdateRemoveQuery[XMLRPC] - xmlrpc.client.Fault: <Fault 115: 'You tried to change the Links field , but only the assignee or reporter of the bug, ...
FAILED tests/test_rw_functional.py::test04NewBugAllFields[REST] - assert [] == [461686, 461687]
FAILED tests/test_rw_functional.py::test05ModifyStatus[REST] - RuntimeError: Command failed with 3
FAILED tests/test_rw_functional.py::test06ModifyEmails[REST] - bugzilla.exceptions.BugzillaError: You do not have permission to remove other people from the CC list. (code=32000)
FAILED tests/test_rw_functional.py::test07ModifyMultiFlags[REST] - RuntimeError: Command failed with 3
FAILED tests/test_rw_functional.py::test07ModifyMisc[REST] - RuntimeError: Command failed with 3
FAILED tests/test_rw_functional.py::test09Whiteboards[REST] - RuntimeError: Command failed with 3
FAILED tests/test_rw_functional.py::test13SubComponents[REST] - bugzilla.exceptions.BugzillaError: You are not authorized to access bug #185526. Most likely the bug has been restrict...
======================================= 15 failed, 134 passed in 204.57s (0:03:24) ========================================

In comparison to the main branch:

...
FAILED tests/test_rw_functional.py::test13SubComponents[REST] - IndexError: list index out of range

@crobinso crobinso left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just some small suggestions.

Also, would be good to test the actual semantics in test_ro_functional.py. Say bugzilla.redhat.com bzapi.getbug(100000000) raises expected error string

Comment thread bugzilla/_backendrest.py
data = paramdict.copy()
data["id"] = listify(bug_ids)
data["alias"] = listify(aliases)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment here explaining why we are doing this: basically it's a hack to keep existing getbug() and getbugs() semantics working in the higher level API

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 🙂


backend.bug_get(_ids, aliases, {})

assert backend.assertion_called is True

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

./setup.py pylint throws some errors. I'm open to modernizing the formatting suggestions here or using tools like pre-commit and/or black, but let's keep this clean until then.

tests/test_backend_rest.py:9: [E501] line too long (85 > 79 characters)
tests/test_backend_rest.py:10: [E501] line too long (90 > 79 characters)
tests/test_backend_rest.py:15: [E501] line too long (86 > 79 characters)
running pylint-3
************* Module tests.test_backend_rest
tests/test_backend_rest.py:17:0: W0613: Unused argument 'kwargs' (unused-argument)
tests/test_backend_rest.py:21:4: W0212: Access to a protected member _get of a client class (protected-access)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! I'm so used to pylint being part of a CI pipeline that I did not check. I have changed the code.

I'm open to modernizing the formatting suggestions

I created a proposal in #185 🙂

@crobinso
crobinso merged commit 2b1281f into python-bugzilla:main Oct 24, 2023
@crazyscientist
crazyscientist deleted the 174-get-single-bug branch October 24, 2023 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IndexError raised in Bugzilla._getbug with REST backend

2 participants