Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-redfish for openSUSE:Factory 
checked in at 2024-09-15 12:37:14
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-redfish (Old)
 and      /work/SRC/openSUSE:Factory/.python-redfish.new.29891 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-redfish"

Sun Sep 15 12:37:14 2024 rev:16 rq:1200964 version:3.2.5

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-redfish/python-redfish.changes    
2024-08-19 23:44:39.892030138 +0200
+++ /work/SRC/openSUSE:Factory/.python-redfish.new.29891/python-redfish.changes 
2024-09-15 12:41:08.460398385 +0200
@@ -1,0 +2,7 @@
+Sat Sep 14 07:03:12 UTC 2024 - Martin Hauke <mar...@gmx.de>
+
+- Update to version 3.2.5
+  * Added new 'check_connectivity' option when creating the
+    client object.
+
+-------------------------------------------------------------------

Old:
----
  redfish-3.2.4.tar.gz

New:
----
  redfish-3.2.5.tar.gz

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

Other differences:
------------------
++++++ python-redfish.spec ++++++
--- /var/tmp/diff_new_pack.WigDLQ/_old  2024-09-15 12:41:09.100425049 +0200
+++ /var/tmp/diff_new_pack.WigDLQ/_new  2024-09-15 12:41:09.104425216 +0200
@@ -2,7 +2,7 @@
 # spec file for package python-redfish
 #
 # Copyright (c) 2024 SUSE LLC
-# Copyright (c) 2020-2021, Martin Hauke <mar...@gmx.de>
+# Copyright (c) 2020-2024, Martin Hauke <mar...@gmx.de>
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -19,7 +19,7 @@
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 Name:           python-redfish
-Version:        3.2.4
+Version:        3.2.5
 Release:        0
 Summary:        Redfish Python Library
 License:        BSD-3-Clause

++++++ redfish-3.2.4.tar.gz -> redfish-3.2.5.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/python-redfish-library-3.2.4/CHANGELOG.md 
new/python-redfish-library-3.2.5/CHANGELOG.md
--- old/python-redfish-library-3.2.4/CHANGELOG.md       2024-08-09 
22:08:10.000000000 +0200
+++ new/python-redfish-library-3.2.5/CHANGELOG.md       2024-09-13 
21:30:33.000000000 +0200
@@ -1,5 +1,8 @@
 # Change Log
 
+## [3.2.5] - 2024-09-13
+- Added new 'check_connectivity' option when creating the client object
+
 ## [3.2.4] - 2024-08-09
 - No code changes; releasing again for PyPI publication
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/python-redfish-library-3.2.4/README.rst 
new/python-redfish-library-3.2.5/README.rst
--- old/python-redfish-library-3.2.4/README.rst 2024-08-09 22:08:10.000000000 
+0200
+++ new/python-redfish-library-3.2.5/README.rst 2024-09-13 21:30:33.000000000 
+0200
@@ -91,6 +91,7 @@
 * ``timeout``: The number of seconds to wait for a response before closing the 
connection.  The default value is ``None``.
 * ``max_retry``: The number of retries to perform an operation before giving 
up.  The default value is ``10``.
 * ``proxies``: A dictionary containing protocol to proxy URL mappings.  The 
default value is ``None``.  See `Using proxies`_.
+* ``check_connectivity``: A boolean value to determine whether the client 
immediately attempts a connection to the base_url. The default is ``True``.
 
 To create a Redfish object, call the ``redfish_client`` method:
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/python-redfish-library-3.2.4/setup.py 
new/python-redfish-library-3.2.5/setup.py
--- old/python-redfish-library-3.2.4/setup.py   2024-08-09 22:08:10.000000000 
+0200
+++ new/python-redfish-library-3.2.5/setup.py   2024-09-13 21:30:33.000000000 
+0200
@@ -12,7 +12,7 @@
     long_description = f.read()
 
 setup(name='redfish',
-      version='3.2.4',
+      version='3.2.5',
       description='Redfish Python Library',
       long_description=long_description,
       long_description_content_type='text/x-rst',
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/python-redfish-library-3.2.4/src/redfish/__init__.py 
new/python-redfish-library-3.2.5/src/redfish/__init__.py
--- old/python-redfish-library-3.2.4/src/redfish/__init__.py    2024-08-09 
22:08:10.000000000 +0200
+++ new/python-redfish-library-3.2.5/src/redfish/__init__.py    2024-09-13 
21:30:33.000000000 +0200
@@ -6,7 +6,7 @@
 """ Redfish restful library """
 
 __all__ = ['rest', 'ris', 'discovery', 'messages']
-__version__ = "3.2.4"
+__version__ = "3.2.5"
 
 from redfish.rest.v1 import redfish_client
 from redfish.rest.v1 import AuthMethod
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/python-redfish-library-3.2.4/src/redfish/rest/v1.py 
new/python-redfish-library-3.2.5/src/redfish/rest/v1.py
--- old/python-redfish-library-3.2.4/src/redfish/rest/v1.py     2024-08-09 
22:08:10.000000000 +0200
+++ new/python-redfish-library-3.2.5/src/redfish/rest/v1.py     2024-09-13 
21:30:33.000000000 +0200
@@ -454,7 +454,7 @@
     def __init__(self, base_url, username=None, password=None,
                                 default_prefix='/redfish/v1/', sessionkey=None,
                                 capath=None, cafile=None, timeout=None,
-                                max_retry=None, proxies=None):
+                                max_retry=None, proxies=None, 
check_connectivity=True):
         """Initialization of the base class RestClientBase
 
         :param base_url: The URL of the remote system
@@ -477,6 +477,9 @@
         :type max_retry: int
         :param proxies: Dictionary containing protocol to proxy URL mappings
         :type proxies: dict
+        :param check_connectivity: A boolean to determine whether the client 
immediately checks for
+        connectivity to the base_url or not.
+        :type check_connectivity: bool
 
         """
 
@@ -497,7 +500,9 @@
         self.default_prefix = default_prefix
         self.capath = capath
         self.cafile = cafile
-        self.get_root_object()
+
+        if check_connectivity:
+            self.get_root_object()
 
     def __enter__(self):
         self.login()
@@ -965,6 +970,8 @@
         :type auth: object/instance of class AuthMethod
 
         """
+        if getattr(self, "root_resp", None) is None:
+            self.get_root_object()
 
         self.__username = username if username else self.__username
         self.__password = password if password else self.__password
@@ -999,7 +1006,7 @@
             message_item = search_message(resp, "Base", 
"PasswordChangeRequired")
             if not message_item is None:
                 raise RedfishPasswordChangeRequiredError("Password Change 
Required\n", message_item["MessageArgs"][0])
-            
+
             if not self.__session_key and resp.status not in [200, 201, 202, 
204]:
                 if resp.status == 401:
                     # Invalid credentials supplied
@@ -1042,7 +1049,7 @@
                                 default_prefix='/redfish/v1/',
                                 sessionkey=None, capath=None,
                                 cafile=None, timeout=None,
-                                max_retry=None, proxies=None):
+                                max_retry=None, proxies=None, 
check_connectivity=True):
         """Initialize HttpClient
 
         :param base_url: The url of the remote system
@@ -1065,17 +1072,21 @@
         :type max_retry: int
         :param proxies: Dictionary containing protocol to proxy URL mappings
         :type proxies: dict
+        :param check_connectivity: A boolean to determine whether the client 
immediately checks for
+        connectivity to the base_url or not.
+        :type check_connectivity: bool
 
         """
         super(HttpClient, self).__init__(base_url, username=username,
                             password=password, default_prefix=default_prefix,
                             sessionkey=sessionkey, capath=capath,
                             cafile=cafile, timeout=timeout,
-                            max_retry=max_retry, proxies=proxies)
+                            max_retry=max_retry, proxies=proxies,
+                            check_connectivity=check_connectivity)
 
         try:
             self.login_url = self.root.Links.Sessions['@odata.id']
-        except KeyError:
+        except (KeyError, AttributeError):
             # While the "Links/Sessions" property is required, we can fallback
             # on the URI hardened in 1.6.0 of the specification if not found
             LOGGER.debug('"Links/Sessions" not found in Service Root.')
@@ -1128,7 +1139,7 @@
                                 default_prefix='/redfish/v1/',
                                 sessionkey=None, capath=None,
                                 cafile=None, timeout=None,
-                                max_retry=None, proxies=None):
+                                max_retry=None, proxies=None, 
check_connectivity=True):
     """Create and return appropriate REDFISH client instance."""
     """ Instantiates appropriate Redfish object based on existing"""
     """ configuration. Use this to retrieve a pre-configured Redfish object
@@ -1153,6 +1164,9 @@
     :type max_retry: int
     :param proxies: Dictionary containing protocol to proxy URL mappings
     :type proxies: dict
+    :param check_connectivity: A boolean to determine whether the client 
immediately checks for
+    connectivity to the base_url or not.
+    :type check_connectivity: bool
     :returns: a client object.
 
     """
@@ -1162,4 +1176,4 @@
     return HttpClient(base_url=base_url, username=username, password=password,
                         default_prefix=default_prefix, sessionkey=sessionkey,
                         capath=capath, cafile=cafile, timeout=timeout,
-                        max_retry=max_retry, proxies=proxies)
+                        max_retry=max_retry, proxies=proxies, 
check_connectivity=check_connectivity)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/python-redfish-library-3.2.4/tests/rest/test_v1.py 
new/python-redfish-library-3.2.5/tests/rest/test_v1.py
--- old/python-redfish-library-3.2.4/tests/rest/test_v1.py      2024-08-09 
22:08:10.000000000 +0200
+++ new/python-redfish-library-3.2.5/tests/rest/test_v1.py      2024-09-13 
21:30:33.000000000 +0200
@@ -4,40 +4,76 @@
 # https://github.com/DMTF/python-redfish-library/blob/main/LICENSE.md
 
 # -*- encoding: utf-8 -*-
+import json
 import unittest
+from unittest import mock
 
-from redfish.rest.v1 import HttpClient
-from redfish.rest.v1 import RetriesExhaustedError
-from redfish.rest.v1 import redfish_client
+from redfish.rest.v1 import HttpClient, RetriesExhaustedError, redfish_client
 
 
 class TestRedFishClient(unittest.TestCase):
-    def test_redfish_client(self):
-        base_url = "http://foo.bar";
-        username = "rstallman"
-        password = "123456"
-        default_prefix = "/custom/redfish/v1/"
-        sessionkey = "fg687glgkf56vlgkf"
-        capath = "/path/to/the/dir"
-        cafile = "filename.test"
-        timeout = 666
-        max_retry = 42
+    def setUp(self) -> None:
+        self.base_url = "http://foo.bar";
+        self.username = "rstallman"
+        self.password = "123456"
+        self.default_prefix = "/custom/redfish/v1/"
+        self.sessionkey = "fg687glgkf56vlgkf"
+        self.capath = "/path/to/the/dir"
+        self.cafile = "filename.test"
+        self.timeout = 666
+        self.max_retry = 42
+
+    def test_redfish_client(self) -> None:
         # NOTE(hberaud) the client try to connect when we initialize the
         # http client object so we need to catch the retries exception first.
         # In a second time we need to mock the six.http_client to simulate
         # server responses and do some other tests
         with self.assertRaises(RetriesExhaustedError):
-            client = redfish_client(base_url=base_url)
+            client = redfish_client(base_url=self.base_url)
             # Check the object type
             self.assertTrue(isinstance(client, HttpClient))
             # Check the object attributes values.
             # Here we check if the client object is properly initialized
-            self.assertEqual(client.base_url, base_url)
-            self.assertEqual(client.username, username)
-            self.assertEqual(client.password, password)
-            self.assertEqual(client.default_prefix, default_prefix)
-            self.assertEqual(client.sessionkey, sessionkey)
-            self.assertEqual(client.capath, capath)
-            self.assertEqual(client.cafile, cafile)
-            self.assertEqual(client.timeout, timeout)
-            self.assertEqual(client.max_retry, max_retry)
+            self.assertEqual(client.base_url, self.base_url)
+            self.assertEqual(client.username, self.username)
+            self.assertEqual(client.password, self.password)
+            self.assertEqual(client.default_prefix, self.default_prefix)
+            self.assertEqual(client.sessionkey, self.sessionkey)
+            self.assertEqual(client.capath, self.capath)
+            self.assertEqual(client.cafile, self.cafile)
+            self.assertEqual(client.timeout, self.timeout)
+            self.assertEqual(client.max_retry, self.max_retry)
+
+    def test_redfish_client_no_root_resp(self) -> None:
+        client = redfish_client(base_url=self.base_url, 
check_connectivity=False)
+        self.assertIsNone(getattr(client, "root_resp", None))
+
+    @mock.patch("requests.Session.request")
+    def test_redfish_client_root_object_initialized_after_login(
+        self, mocked_request: mock.Mock
+    ) -> None:
+        dummy_root_data = '{"Links": {"Sessions": {"@data.id": 
"/redfish/v1/SessionService/Sessions"}}}'
+        dummy_session_response = (
+            '{"@odata.type": "#Session.v1_1_2.Session", '
+            '"@odata.id": "/redfish/v1/SessionService/Sessions/1", '
+            '"Id": "1", "Name": "User Session", "Description": "Manager User 
Session", '
+            '"UserName": "user", "Oem": {}}'
+        )
+        root_resp = mock.Mock(content=dummy_root_data, status_code=200)
+        auth_resp = mock.Mock(
+            content=dummy_session_response,
+            status_code=200,
+            headers={"location": "fake", "x-auth-token": "fake"},
+        )
+        mocked_request.side_effect = [
+            root_resp,
+            auth_resp,
+        ]
+        client = redfish_client(base_url=self.base_url, 
check_connectivity=False)
+        client.login()
+
+        self.assertEqual(client.root, json.loads(dummy_root_data))
+
+
+if __name__ == "__main__":
+    unittest.main()

Reply via email to