File: test_backend_rest.py

package info (click to toggle)
python-bugzilla 3.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,116 kB
  • sloc: python: 6,160; makefile: 7
file content (35 lines) | stat: -rw-r--r-- 1,178 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from types import MethodType

from bugzilla._backendrest import _BackendREST
from bugzilla._session import _BugzillaSession


def test_getbug():
    session = _BugzillaSession(url="http://example.com",
                               user_agent="py-bugzilla-test",
                               sslverify=False,
                               cert=None,
                               tokencache={},
                               api_key="",
                               is_redhat_bugzilla=False)
    backend = _BackendREST(url="http://example.com",
                           bugzillasession=session)

    def _assertion(self, *args):
        self.assertion_called = True
        assert args and args[0] == url

    setattr(backend, "_get", MethodType(_assertion, backend))

    for _ids, aliases, url in (
            (1, None, "/bug/1"),
            ([1], [], "/bug/1"),
            (None, "CVE-1999-0001", "/bug/CVE-1999-0001"),
            ([], ["CVE-1999-0001"], "/bug/CVE-1999-0001"),
            (1, "CVE-1999-0001", "/bug"),
    ):
        backend.assertion_called = False

        backend.bug_get(_ids, aliases, {})

        assert backend.assertion_called is True