|
8 | 8 | """ |
9 | 9 | Unit tests that do readonly functional tests against real bugzilla instances. |
10 | 10 | """ |
| 11 | +from xmlrpc.client import Fault |
| 12 | + |
11 | 13 | import pytest |
12 | 14 |
|
13 | 15 | import bugzilla |
| 16 | +from bugzilla.exceptions import BugzillaError |
14 | 17 | import tests |
15 | 18 |
|
16 | 19 |
|
@@ -295,6 +298,38 @@ def testGetBugAlias(backends): |
295 | 298 | assert bug.bug_id == 720773 |
296 | 299 |
|
297 | 300 |
|
| 301 | +def testGetBug404(backends): |
| 302 | + """ |
| 303 | + getbug() is expected to raise an error, if a bug ID or alias does not exist |
| 304 | + """ |
| 305 | + bz = _open_bz(REDHAT_URL, **backends) |
| 306 | + |
| 307 | + try: |
| 308 | + bz.getbug(100000000) |
| 309 | + except Fault as error: # XMLRPC API |
| 310 | + assert error.faultCode == 101 |
| 311 | + except BugzillaError as error: # REST API |
| 312 | + assert error.code == 101 |
| 313 | + else: |
| 314 | + raise AssertionError("No exception raised") |
| 315 | + |
| 316 | + |
| 317 | +def testGetBugAlias404(backends): |
| 318 | + """ |
| 319 | + getbug() is expected to raise an error, if a bug ID or alias does not exist |
| 320 | + """ |
| 321 | + bz = _open_bz(REDHAT_URL, **backends) |
| 322 | + |
| 323 | + try: |
| 324 | + bz.getbug("CVE-1234-4321") |
| 325 | + except Fault as error: # XMLRPC API |
| 326 | + assert error.faultCode == 100 |
| 327 | + except BugzillaError as error: # REST API |
| 328 | + assert error.code == 100 |
| 329 | + else: |
| 330 | + raise AssertionError("No exception raised") |
| 331 | + |
| 332 | + |
298 | 333 | def testQuerySubComponent(run_cli, backends): |
299 | 334 | bz = _open_bz(REDHAT_URL, **backends) |
300 | 335 |
|
|
0 commit comments