Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-pynetbox for openSUSE:Factory 
checked in at 2021-04-10 15:27:54
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-pynetbox (Old)
 and      /work/SRC/openSUSE:Factory/.python-pynetbox.new.2401 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-pynetbox"

Sat Apr 10 15:27:54 2021 rev:22 rq:884069 version:6.1.1

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-pynetbox/python-pynetbox.changes  
2021-04-08 21:32:25.799824540 +0200
+++ 
/work/SRC/openSUSE:Factory/.python-pynetbox.new.2401/python-pynetbox.changes    
    2021-04-10 15:29:00.934494085 +0200
@@ -1,0 +2,13 @@
+Fri Apr  9 09:36:47 UTC 2021 - Martin Hauke <mar...@gmx.de>
+
+- Update to version 6.1.1
+  * Fixes issue with duplicate returns when threading is enabled.
+  * Fixes updates to config_context data.
+  * Re-implements ValueError from Endpoint.get() when used with
+    kwargs and more than one result is found.
+- Update to version 6.1.0
+  * Adds a __next__ method to RecordSet objects.
+- Update to version 6.0.2
+  * Fix len() calls for empty RecordSet.
+
+-------------------------------------------------------------------

Old:
----
  pynetbox-6.0.1.tar.gz

New:
----
  pynetbox-6.1.1.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-pynetbox.spec ++++++
--- /var/tmp/diff_new_pack.FuVVRy/_old  2021-04-10 15:29:01.410494645 +0200
+++ /var/tmp/diff_new_pack.FuVVRy/_new  2021-04-10 15:29:01.410494645 +0200
@@ -18,7 +18,7 @@
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 Name:           python-pynetbox
-Version:        6.0.1
+Version:        6.1.1
 Release:        0
 Summary:        NetBox API client library
 License:        Apache-2.0

++++++ pynetbox-6.0.1.tar.gz -> pynetbox-6.1.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pynetbox-6.0.1/PKG-INFO new/pynetbox-6.1.1/PKG-INFO
--- old/pynetbox-6.0.1/PKG-INFO 2021-04-06 06:10:10.126413600 +0200
+++ new/pynetbox-6.1.1/PKG-INFO 2021-04-09 02:16:52.918451800 +0200
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: pynetbox
-Version: 6.0.1
+Version: 6.1.1
 Summary: NetBox API client library
 Home-page: https://github.com/digitalocean/pynetbox
 Author: Zach Moody
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pynetbox-6.0.1/pynetbox/core/endpoint.py 
new/pynetbox-6.1.1/pynetbox/core/endpoint.py
--- old/pynetbox-6.0.1/pynetbox/core/endpoint.py        2021-04-06 
06:10:00.000000000 +0200
+++ new/pynetbox-6.1.1/pynetbox/core/endpoint.py        2021-04-09 
02:16:40.000000000 +0200
@@ -133,7 +133,19 @@
             key = None
 
         if not key:
-            return next(iter(self.filter(**kwargs)), None)
+            resp = self.filter(**kwargs)
+            ret = next(resp, None)
+            if not ret:
+                return ret
+            try:
+                next(resp)
+                raise ValueError(
+                    "get() returned more than one result. "
+                    "Check that the kwarg(s) passed are valid for this "
+                    "endpoint or use filter() or all() instead."
+                )
+            except StopIteration:
+                return ret
 
         req = Request(
             key=key,
@@ -143,7 +155,7 @@
             http_session=self.api.http_session,
         )
         try:
-            return next(iter(RecordSet(self, req)), None)
+            return next(RecordSet(self, req), None)
         except RequestError as e:
             if e.req.status_code == 404:
                 return None
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pynetbox-6.0.1/pynetbox/core/query.py 
new/pynetbox-6.1.1/pynetbox/core/query.py
--- old/pynetbox-6.0.1/pynetbox/core/query.py   2021-04-06 06:10:00.000000000 
+0200
+++ new/pynetbox-6.1.1/pynetbox/core/query.py   2021-04-09 02:16:40.000000000 
+0200
@@ -327,25 +327,26 @@
                         self.concurrent_get(ret, page_size, page_offsets)
                 for i in ret:
                     yield i
-            first_run = True
-            for i in req["results"]:
-                yield i
-            while req["next"]:
-                # Not worrying about making sure add_params kwargs is
-                # passed in here because results from detail routes aren't
-                # paginated, thus far.
-                if first_run:
-                    req = self._make_call(
-                        add_params={
-                            "limit": self.limit or req["count"],
-                            "offset": len(req["results"]),
-                        }
-                    )
-                else:
-                    req = self._make_call(url_override=req["next"])
-                first_run = False
+            else:
+                first_run = True
                 for i in req["results"]:
                     yield i
+                while req["next"]:
+                    # Not worrying about making sure add_params kwargs is
+                    # passed in here because results from detail routes aren't
+                    # paginated, thus far.
+                    if first_run:
+                        req = self._make_call(
+                            add_params={
+                                "limit": self.limit or req["count"],
+                                "offset": len(req["results"]),
+                            }
+                        )
+                    else:
+                        req = self._make_call(url_override=req["next"])
+                    first_run = False
+                    for i in req["results"]:
+                        yield i
         elif isinstance(req, list):
             self.count = len(req)
             for i in req:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pynetbox-6.0.1/pynetbox/core/response.py 
new/pynetbox-6.1.1/pynetbox/core/response.py
--- old/pynetbox-6.0.1/pynetbox/core/response.py        2021-04-06 
06:10:00.000000000 +0200
+++ new/pynetbox-6.1.1/pynetbox/core/response.py        2021-04-09 
02:16:40.000000000 +0200
@@ -78,16 +78,25 @@
         self._response_cache = []
 
     def __iter__(self):
-        for i in self._response_cache:
-            yield self.endpoint.return_obj(i, self.endpoint.api, self.endpoint)
-        for i in self.response:
-            yield self.endpoint.return_obj(i, self.endpoint.api, self.endpoint)
+        return self
+
+    def __next__(self):
+        if self._response_cache:
+            return self.endpoint.return_obj(
+                self._response_cache.pop(), self.endpoint.api, self.endpoint
+            )
+        return self.endpoint.return_obj(
+            next(self.response), self.endpoint.api, self.endpoint
+        )
 
     def __len__(self):
         try:
             return self.request.count
         except AttributeError:
-            self._response_cache.append(next(self.response))
+            try:
+                self._response_cache.append(next(self.response))
+            except StopIteration:
+                return 0
             return self.request.count
 
 
@@ -259,10 +268,7 @@
 
     def _add_cache(self, item):
         key, value = item
-        if key == "local_context_data":
-            self._init_cache.append((key, copy.deepcopy(value)))
-        else:
-            self._init_cache.append((key, get_return(value)))
+        self._init_cache.append((key, get_return(value)))
 
     def _parse_values(self, values):
         """ Parses values init arg.
@@ -282,7 +288,7 @@
                 if k in ["custom_fields", "local_context_data"] or hasattr(
                     lookup, "_json_field"
                 ):
-                    self._add_cache((k, v.copy()))
+                    self._add_cache((k, copy.deepcopy(v)))
                     setattr(self, k, v)
                     continue
                 if lookup:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pynetbox-6.0.1/pynetbox.egg-info/PKG-INFO 
new/pynetbox-6.1.1/pynetbox.egg-info/PKG-INFO
--- old/pynetbox-6.0.1/pynetbox.egg-info/PKG-INFO       2021-04-06 
06:10:09.000000000 +0200
+++ new/pynetbox-6.1.1/pynetbox.egg-info/PKG-INFO       2021-04-09 
02:16:52.000000000 +0200
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: pynetbox
-Version: 6.0.1
+Version: 6.1.1
 Summary: NetBox API client library
 Home-page: https://github.com/digitalocean/pynetbox
 Author: Zach Moody
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pynetbox-6.0.1/pynetbox.egg-info/SOURCES.txt 
new/pynetbox-6.1.1/pynetbox.egg-info/SOURCES.txt
--- old/pynetbox-6.0.1/pynetbox.egg-info/SOURCES.txt    2021-04-06 
06:10:10.000000000 +0200
+++ new/pynetbox-6.1.1/pynetbox.egg-info/SOURCES.txt    2021-04-09 
02:16:52.000000000 +0200
@@ -160,6 +160,7 @@
 tests/integration/test_ipam.py
 tests/unit/__init__.py
 tests/unit/test_endpoint.py
+tests/unit/test_extras.py
 tests/unit/test_query.py
 tests/unit/test_request.py
 tests/unit/test_response.py
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pynetbox-6.0.1/tests/integration/conftest.py 
new/pynetbox-6.1.1/tests/integration/conftest.py
--- old/pynetbox-6.0.1/tests/integration/conftest.py    2021-04-06 
06:10:00.000000000 +0200
+++ new/pynetbox-6.1.1/tests/integration/conftest.py    2021-04-09 
02:16:40.000000000 +0200
@@ -357,7 +357,7 @@
 
 
 @pytest.fixture(scope="session")
-def netbox_service(
+def docker_netbox_service(
     pytestconfig, docker_ip, docker_services, request,
 ):
     """Get the netbox service to test against.
@@ -411,23 +411,23 @@
     docker_services.wait_until_responsive(
         timeout=300.0, pause=1, check=lambda: netbox_is_responsive(url)
     )
-    nb_api = pynetbox.api(url, 
token="0123456789abcdef0123456789abcdef01234567")
 
     return {
         "url": url,
         "netbox_version": netbox_integration_version,
-        "api": nb_api,
     }
 
 
-@pytest.fixture(scope="session", autouse=True)
-def api(netbox_service):
-    return netbox_service["api"]
+@pytest.fixture(scope="session")
+def api(docker_netbox_service):
+    return pynetbox.api(
+        docker_netbox_service["url"], 
token="0123456789abcdef0123456789abcdef01234567"
+    )
 
 
 @pytest.fixture(scope="session")
-def nb_version(netbox_service):
-    return netbox_service["netbox_version"]
+def nb_version(docker_netbox_service):
+    return docker_netbox_service["netbox_version"]
 
 
 @pytest.fixture(scope="session")
@@ -469,12 +469,12 @@
 
 def pytest_generate_tests(metafunc):
     """Dynamically parametrize some functions based on args from the cli 
parser."""
-    if "netbox_service" in metafunc.fixturenames:
-        # parametrize the requested versions of netbox to the netbox_services 
fixture
+    if "docker_netbox_service" in metafunc.fixturenames:
+        # parametrize the requested versions of netbox to the 
docker_netbox_services fixture
         # so that it will return a fixture for each of the versions requested
         # individually rather than one fixture with multiple versions within it
         metafunc.parametrize(
-            "netbox_service",
+            "docker_netbox_service",
             metafunc.config.getoption("netbox_versions"),
             ids=id_netbox_service,
             indirect=True,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pynetbox-6.0.1/tests/integration/test_dcim.py 
new/pynetbox-6.1.1/tests/integration/test_dcim.py
--- old/pynetbox-6.0.1/tests/integration/test_dcim.py   2021-04-06 
06:10:00.000000000 +0200
+++ new/pynetbox-6.1.1/tests/integration/test_dcim.py   2021-04-09 
02:16:40.000000000 +0200
@@ -1,6 +1,8 @@
 import pytest
 from packaging import version
 
+import pynetbox
+
 
 @pytest.fixture(scope="module")
 def rack(api, site):
@@ -86,6 +88,27 @@
             endpoint="sites",
         )
 
+    @pytest.fixture(scope="class")
+    def add_sites(self, api):
+        sites = [
+            api.dcim.sites.create(name="test{}".format(i), 
slug="test{}".format(i))
+            for i in range(2, 20)
+        ]
+        yield
+        for i in sites:
+            i.delete()
+
+    def test_threading_duplicates(self, docker_netbox_service, add_sites):
+        api = pynetbox.api(
+            docker_netbox_service["url"],
+            token="0123456789abcdef0123456789abcdef01234567",
+            threading=True,
+        )
+        test = api.dcim.sites.all(limit=5)
+        test_list = list(test)
+        test_set = set(test_list)
+        assert len(test_list) == len(test_set)
+
 
 class TestRack(BaseTest):
     @pytest.fixture(scope="class")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pynetbox-6.0.1/tests/unit/test_endpoint.py 
new/pynetbox-6.1.1/tests/unit/test_endpoint.py
--- old/pynetbox-6.0.1/tests/unit/test_endpoint.py      2021-04-06 
06:10:00.000000000 +0200
+++ new/pynetbox-6.1.1/tests/unit/test_endpoint.py      2021-04-09 
02:16:40.000000000 +0200
@@ -59,3 +59,36 @@
             choices = test_obj.choices()
             self.assertEqual(choices["letter"][1]["display_name"], "B")
             self.assertEqual(choices["letter"][1]["value"], 2)
+
+    def test_get_with_filter(self):
+        with patch(
+            "pynetbox.core.query.Request._make_call", return_value=Mock()
+        ) as mock:
+            mock.return_value = [{"id": 123}]
+            api = Mock(base_url="http://localhost:8000/api";)
+            app = Mock(name="test")
+            test_obj = Endpoint(api, app, "test")
+            test = test_obj.get(name="test")
+            self.assertEqual(test.id, 123)
+
+    def test_get_greater_than_one(self):
+        with patch(
+            "pynetbox.core.query.Request._make_call", return_value=Mock()
+        ) as mock:
+            mock.return_value = [{"id": 123}, {"id": 321}]
+            api = Mock(base_url="http://localhost:8000/api";)
+            app = Mock(name="test")
+            test_obj = Endpoint(api, app, "test")
+            with self.assertRaises(ValueError) as _:
+                test_obj.get(name="test")
+
+    def test_get_no_results(self):
+        with patch(
+            "pynetbox.core.query.Request._make_call", return_value=Mock()
+        ) as mock:
+            mock.return_value = []
+            api = Mock(base_url="http://localhost:8000/api";)
+            app = Mock(name="test")
+            test_obj = Endpoint(api, app, "test")
+            test = test_obj.get(name="test")
+            self.assertIsNone(test)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pynetbox-6.0.1/tests/unit/test_extras.py 
new/pynetbox-6.1.1/tests/unit/test_extras.py
--- old/pynetbox-6.0.1/tests/unit/test_extras.py        1970-01-01 
01:00:00.000000000 +0100
+++ new/pynetbox-6.1.1/tests/unit/test_extras.py        2021-04-09 
02:16:40.000000000 +0200
@@ -0,0 +1,40 @@
+import unittest
+
+import six
+
+from pynetbox.models.extras import ConfigContexts
+
+
+class ExtrasTestCase(unittest.TestCase):
+    def test_config_contexts(self):
+        test_values = {
+            "data": {"test_int": 123, "test_str": "testing", "test_list": [1, 
2, 3],}
+        }
+        test = ConfigContexts(test_values, None, None)
+        self.assertTrue(test)
+
+    def test_config_contexts_diff_str(self):
+        test_values = {
+            "data": {
+                "test_int": 123,
+                "test_str": "testing",
+                "test_list": [1, 2, 3],
+                "test_dict": {"foo": "bar"},
+            }
+        }
+        test = ConfigContexts(test_values, None, None)
+        test.data["test_str"] = "bar"
+        self.assertEqual(test._diff(), {"data"})
+
+    def test_config_contexts_diff_dict(self):
+        test_values = {
+            "data": {
+                "test_int": 123,
+                "test_str": "testing",
+                "test_list": [1, 2, 3],
+                "test_dict": {"foo": "bar"},
+            }
+        }
+        test = ConfigContexts(test_values, None, None)
+        test.data["test_dict"].update({"bar": "foo"})
+        self.assertEqual(test._diff(), {"data"})

Reply via email to