|
4 | 4 | from bugzilla._session import _BugzillaSession |
5 | 5 |
|
6 | 6 |
|
7 | | -def test_getbug(): |
8 | | - session = _BugzillaSession(url="http://example.com", |
| 7 | +class TestGetBug: |
| 8 | + @property |
| 9 | + def session(self): |
| 10 | + return _BugzillaSession(url="http://example.com", |
9 | 11 | user_agent="py-bugzilla-test", |
10 | 12 | sslverify=False, |
11 | 13 | cert=None, |
12 | 14 | tokencache={}, |
13 | 15 | api_key="", |
14 | 16 | is_redhat_bugzilla=False) |
15 | | - backend = _BackendREST(url="http://example.com", |
16 | | - bugzillasession=session) |
17 | 17 |
|
18 | | - def _assertion(self, *args): |
19 | | - self.assertion_called = True |
20 | | - assert args and args[0] == url |
| 18 | + @property |
| 19 | + def backend(self): |
| 20 | + return _BackendREST(url="http://example.com", |
| 21 | + bugzillasession=self.session) |
21 | 22 |
|
22 | | - setattr(backend, "_get", MethodType(_assertion, backend)) |
| 23 | + def test_getbug__not_permissive(self): |
| 24 | + backend = self.backend |
23 | 25 |
|
24 | | - for _ids, aliases, url in ( |
25 | | - (1, None, "/bug/1"), |
26 | | - ([1], [], "/bug/1"), |
27 | | - (None, "CVE-1999-0001", "/bug/CVE-1999-0001"), |
28 | | - ([], ["CVE-1999-0001"], "/bug/CVE-1999-0001"), |
29 | | - (1, "CVE-1999-0001", "/bug"), |
30 | | - ): |
31 | | - backend.assertion_called = False |
| 26 | + def _assertion(self, *args): |
| 27 | + self.assertion_called = True |
| 28 | + assert args and args[0] == url |
32 | 29 |
|
33 | | - backend.bug_get(_ids, aliases, {}) |
| 30 | + setattr(backend, "_get", MethodType(_assertion, backend)) |
34 | 31 |
|
35 | | - assert backend.assertion_called is True |
| 32 | + for _ids, aliases, url in ( |
| 33 | + (1, None, "/bug/1"), |
| 34 | + ([1], [], "/bug/1"), |
| 35 | + (None, "CVE-1999-0001", "/bug/CVE-1999-0001"), |
| 36 | + ([], ["CVE-1999-0001"], "/bug/CVE-1999-0001"), |
| 37 | + (1, "CVE-1999-0001", "/bug"), |
| 38 | + ([1, 2], None, "/bug") |
| 39 | + ): |
| 40 | + backend.assertion_called = False |
| 41 | + |
| 42 | + backend.bug_get(_ids, aliases, {}) |
| 43 | + |
| 44 | + assert backend.assertion_called is True |
0 commit comments