diff options
| author | Scott Bahling <sbahling@suse.com> | 2020-02-12 18:38:33 +0100 |
|---|---|---|
| committer | Scott Bahling <sbahling@suse.com> | 2020-02-12 18:38:33 +0100 |
| commit | 7806de5f05bbc153b8405f1e693e1ae202e2a54c (patch) | |
| tree | 44097318002add0f5e076cb057d10e9edca06ba4 /test | |
| parent | 9b0d40c28f86e58df131b7971e2c0640d77a01a1 (diff) | |
| download | obsapi-7806de5f05bbc153b8405f1e693e1ae202e2a54c.tar.gz obsapi-7806de5f05bbc153b8405f1e693e1ae202e2a54c.tar.xz obsapi-7806de5f05bbc153b8405f1e693e1ae202e2a54c.zip | |
Implement sub-api callbackso
When an api object makes an API request to the OBS server, in
addition to returning the results, it sends a reference to
itself to the registered callback function (if set).
We use this to track the last api object called so we can access
the last raw request response.
Diffstat (limited to 'test')
| -rw-r--r-- | test/test_api.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/test_api.py b/test/test_api.py index 50afeca..09b2806 100644 --- a/test/test_api.py +++ b/test/test_api.py @@ -1,7 +1,9 @@ import re import pytest import os +import requests_mock as rmock from . import test_dir +from obsapi.null import Null from obsapi import ObsApi from lxml import etree try: @@ -202,6 +204,20 @@ def locked_package_meta(): </package>""" +def test_callback(requests_mock): + """ + Test that api callback works and returns a reference to + the sub-api instance + """ + text = '<project/>' + requests_mock.get(rmock.ANY, text=text) + assert isinstance(api.lastapi, type(Null)) + api.build.get(prj=prj) + assert api.lastapi is api.build + api.source.get(prj=prj) + assert api.lastapi is api.source + + def test_get_project_meta(requests_mock): matcher = prj_meta_re text = '<project/>' |
