Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-mocket for openSUSE:Factory 
checked in at 2021-12-12 21:26:58
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-mocket (Old)
 and      /work/SRC/openSUSE:Factory/.python-mocket.new.2520 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-mocket"

Sun Dec 12 21:26:58 2021 rev:17 rq:937323 version:3.10.2

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-mocket/python-mocket.changes      
2021-10-20 20:23:50.341361583 +0200
+++ /work/SRC/openSUSE:Factory/.python-mocket.new.2520/python-mocket.changes    
2021-12-12 21:26:59.948319849 +0100
@@ -1,0 +2,39 @@
+Wed Dec  1 21:17:39 UTC 2021 - Sebastian Wagner <sebix+novell....@sebix.at>
+
+- - Help the user to spot issues (#166)
+   * Help to detect `register()` misusage.
+   * Bump version.
+   * Improve DeepSource scans.
+ - Newer `pipenv` and GIT hooks (#165)
+   * Newer GIT hooks.
+ - Remove implicit `object` from the base class (#164)
+   Co-authored-by: deepsource-autofix[bot] 
<62050782+deepsource-autofix[bot]@users.noreply.github.com>
+ - Change methods not using its bound instance to staticmethods (#163)
+   Co-authored-by: deepsource-autofix[bot] 
<62050782+deepsource-autofix[bot]@users.noreply.github.com>
+ - Add .deepsource.toml
+ - Replace `dict` call with comprehension (#162)
+   Co-authored-by: deepsource-autofix[bot] 
<62050782+deepsource-autofix[bot]@users.noreply.github.com>
+ - Refactor unnecessary `else` / `elif` when `if` block has a `return` 
statement (#161)
+   Co-authored-by: deepsource-autofix[bot] 
<62050782+deepsource-autofix[bot]@users.noreply.github.com>
+ - Remove unnecessary generator (#160)
+   Co-authored-by: deepsource-autofix[bot] 
<62050782+deepsource-autofix[bot]@users.noreply.github.com>
+ - Multi `register()` (#159)
+   * Add failing test.
+   * `Entry.collect` let us know if the response should be consumed or not.
+   * Bump version.
+ - Update README.rst
+ - Update main.yml
+ - In PYPI the package is old and broken
+
+-------------------------------------------------------------------
+Sat Nov 27 10:12:44 UTC 2021 - Sebastian Wagner <sebix+novell....@sebix.at>
+
+- - Multi `register()` (#159)
+   * Add failing test.
+   * `Entry.collect` let us know if the response should be consumed or not.
+   * Bump version.
+ - Update README.rst
+ - Update main.yml
+ - In PYPI the package is old and broken
+
+-------------------------------------------------------------------

Old:
----
  mocket-3.10.0.tar.gz

New:
----
  mocket-3.10.2.tar.gz

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

Other differences:
------------------
++++++ python-mocket.spec ++++++
--- /var/tmp/diff_new_pack.883DI9/_old  2021-12-12 21:27:02.160321159 +0100
+++ /var/tmp/diff_new_pack.883DI9/_new  2021-12-12 21:27:02.160321159 +0100
@@ -26,7 +26,7 @@
 %bcond_with test
 %endif
 Name:           python-mocket%{psuffix}
-Version:        3.10.0
+Version:        3.10.2
 Release:        0
 Summary:        Python socket mock framework
 License:        BSD-3-Clause

++++++ mocket-3.10.0.tar.gz -> mocket-3.10.2.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mocket-3.10.0/PKG-INFO new/mocket-3.10.2/PKG-INFO
--- old/mocket-3.10.0/PKG-INFO  2021-09-23 11:06:41.487060500 +0200
+++ new/mocket-3.10.2/PKG-INFO  2021-12-01 19:58:33.368794700 +0100
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: mocket
-Version: 3.10.0
+Version: 3.10.2
 Summary: Socket Mock Framework - for all kinds of socket animals, web-clients 
included -         with gevent/asyncio/SSL support
 Home-page: https://github.com/mindflayer/python-mocket
 Author: Giorgio Salluzzo
@@ -39,9 +39,6 @@
 .. image:: 
https://img.shields.io/lgtm/grade/python/g/mindflayer/python-mocket.svg?logo=lgtm&logoWidth=18
    :target: https://lgtm.com/projects/g/mindflayer/python-mocket/context:python
 
-.. image:: 
https://requires.io/github/mindflayer/python-mocket/requirements.svg?branch=master
-     :target: 
https://requires.io/github/mindflayer/python-mocket/requirements/?branch=master
-     :alt: Requirements Status
 
 A socket mock framework
 -------------------------
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mocket-3.10.0/README.rst new/mocket-3.10.2/README.rst
--- old/mocket-3.10.0/README.rst        2021-08-31 12:37:51.000000000 +0200
+++ new/mocket-3.10.2/README.rst        2021-11-23 19:02:53.000000000 +0100
@@ -11,9 +11,6 @@
 .. image:: 
https://img.shields.io/lgtm/grade/python/g/mindflayer/python-mocket.svg?logo=lgtm&logoWidth=18
    :target: https://lgtm.com/projects/g/mindflayer/python-mocket/context:python
 
-.. image:: 
https://requires.io/github/mindflayer/python-mocket/requirements.svg?branch=master
-     :target: 
https://requires.io/github/mindflayer/python-mocket/requirements/?branch=master
-     :alt: Requirements Status
 
 A socket mock framework
 -------------------------
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mocket-3.10.0/mocket/__init__.py 
new/mocket-3.10.2/mocket/__init__.py
--- old/mocket-3.10.0/mocket/__init__.py        2021-09-23 11:01:03.000000000 
+0200
+++ new/mocket-3.10.2/mocket/__init__.py        2021-12-01 19:57:28.000000000 
+0100
@@ -2,4 +2,4 @@
 
 __all__ = ("mocketize", "Mocket", "MocketEntry", "Mocketizer")
 
-__version__ = "3.10.0"
+__version__ = "3.10.2"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mocket-3.10.0/mocket/compat.py 
new/mocket-3.10.2/mocket/compat.py
--- old/mocket-3.10.0/mocket/compat.py  2021-03-20 19:51:56.000000000 +0100
+++ new/mocket-3.10.2/mocket/compat.py  2021-12-01 19:25:53.000000000 +0100
@@ -30,9 +30,8 @@
     if hasattr(lib_magic, "from_buffer"):
         # PyPI python-magic
         return lib_magic.from_buffer(body, mime=True)
-    else:
-        # file's builtin python wrapper
-        # used by 
https://www.archlinux.org/packages/community/any/python-mocket/
-        _magic = lib_magic.open(lib_magic.MAGIC_MIME_TYPE)
-        _magic.load()
-        return _magic.buffer(body)
+    # file's builtin python wrapper
+    # used by https://www.archlinux.org/packages/community/any/python-mocket/
+    _magic = lib_magic.open(lib_magic.MAGIC_MIME_TYPE)
+    _magic.load()
+    return _magic.buffer(body)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mocket-3.10.0/mocket/mocket.py 
new/mocket-3.10.2/mocket/mocket.py
--- old/mocket-3.10.0/mocket/mocket.py  2021-09-23 11:01:03.000000000 +0200
+++ new/mocket-3.10.2/mocket/mocket.py  2021-12-01 19:25:53.000000000 +0100
@@ -52,7 +52,7 @@
 true_urllib3_match_hostname = urllib3_match_hostname
 
 
-class SuperFakeSSLContext(object):
+class SuperFakeSSLContext:
     """For Python 3.6"""
 
     class FakeSetter(int):
@@ -108,7 +108,8 @@
         sock._secure_socket = True
         return sock
 
-    def wrap_bio(self, incoming, outcoming, *args, **kwargs):
+    @staticmethod
+    def wrap_bio(incoming, outcoming, *args, **kwargs):
         ssl_obj = MocketSocket()
         ssl_obj._host = kwargs["server_hostname"]
         return ssl_obj
@@ -130,7 +131,7 @@
     return h(encode_to_bytes("".join(sorted(req.split("\r\n"))))).hexdigest()
 
 
-class MocketSocket(object):
+class MocketSocket:
     timeout = None
     _fd = None
     family = None
@@ -191,7 +192,8 @@
     def settimeout(self, timeout):
         self.timeout = timeout
 
-    def getsockopt(self, level, optname, buflen=None):
+    @staticmethod
+    def getsockopt(level, optname, buflen=None):
         return socket.SOCK_STREAM
 
     def do_handshake(self):
@@ -232,7 +234,8 @@
     def write(self, data):
         return self.send(encode_to_bytes(data))
 
-    def fileno(self):
+    @staticmethod
+    def fileno():
         Mocket.r_fd, Mocket.w_fd = os.pipe()
         return Mocket.r_fd
 
@@ -253,15 +256,19 @@
             entry = self.get_entry(data)
 
         if entry:
-            entry.collect(data)
-            response = entry.get_response()
+            consume_response = entry.collect(data)
+            if consume_response is not False:
+                response = entry.get_response()
+            else:
+                response = None
         else:
             response = self.true_sendall(data, *args, **kwargs)
 
-        self.fd.seek(0)
-        self.fd.write(response)
-        self.fd.truncate()
-        self.fd.seek(0)
+        if response is not None:
+            self.fd.seek(0)
+            self.fd.write(response)
+            self.fd.truncate()
+            self.fd.seek(0)
 
     def read(self, buffersize):
         return self.fd.read(buffersize)
@@ -396,7 +403,7 @@
         return do_nothing
 
 
-class Mocket(object):
+class Mocket:
     _entries = collections.defaultdict(list)
     _requests = []
     _namespace = text_type(id(_entries))
@@ -533,12 +540,13 @@
         ), "Some Mocket entries have not been served"
 
 
-class MocketEntry(object):
+class MocketEntry:
     class Response(byte_type):
         @property
         def data(self):
             return self
 
+    response_index = 0
     request_cls = str
     response_cls = Response
     responses = None
@@ -547,7 +555,6 @@
     def __init__(self, location, responses):
         self._served = False
         self.location = location
-        self.response_index = 0
 
         if not isinstance(responses, collections_abc.Iterable) or isinstance(
             responses, basestring
@@ -567,7 +574,8 @@
                     r = self.response_cls(r)
                 self.responses.append(r)
 
-    def can_handle(self, data):
+    @staticmethod
+    def can_handle(data):
         return True
 
     def collect(self, data):
@@ -587,7 +595,7 @@
         return response.data
 
 
-class Mocketizer(object):
+class Mocketizer:
     def __init__(self, instance=None, namespace=None, 
truesocket_recording_dir=None):
         self.instance = instance
         self.truesocket_recording_dir = truesocket_recording_dir
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mocket-3.10.0/mocket/mockhttp.py 
new/mocket-3.10.2/mocket/mockhttp.py
--- old/mocket-3.10.0/mocket/mockhttp.py        2021-03-20 19:51:56.000000000 
+0100
+++ new/mocket-3.10.2/mocket/mockhttp.py        2021-12-01 19:57:28.000000000 
+0100
@@ -17,7 +17,7 @@
     magic = None
 
 
-STATUS = dict([(k, v[0]) for k, v in BaseHTTPRequestHandler.responses.items()])
+STATUS = {k: v[0] for k, v in BaseHTTPRequestHandler.responses.items()}
 CRLF = "\r\n"
 
 
@@ -51,7 +51,7 @@
         return "{} - {} - {}".format(self.method, self.path, self.headers)
 
 
-class Response(object):
+class Response:
     headers = None
     is_file_object = False
 
@@ -149,14 +149,20 @@
         self._match_querystring = match_querystring
 
     def collect(self, data):
+        consume_response = True
+
         decoded_data = decode_from_bytes(data)
         if not decoded_data.startswith(Entry.METHODS):
             Mocket.remove_last_request()
             self._sent_data += data
+            consume_response = False
         else:
             self._sent_data = data
+
         super(Entry, self).collect(self._sent_data)
 
+        return consume_response
+
     def can_handle(self, data):
         r"""
         >>> e = Entry('http://www.github.com/?bar=foo&foobar', Entry.GET, 
(Response(b'<html/>'),))
@@ -170,10 +176,8 @@
             requestline, _ = decode_from_bytes(data).split(CRLF, 1)
             method, path, version = self._parse_requestline(requestline)
         except ValueError:
-            try:
-                return self == Mocket._last_entry
-            except AttributeError:
-                return False
+            return self is getattr(Mocket, "_last_entry", None)
+
         uri = urlsplit(path)
         can_handle = uri.path == self.path and method == self.method
         if self._match_querystring:
@@ -204,12 +208,14 @@
         )
         if m:
             return m.group(1).upper(), m.group(2), m.group(3)
-        else:
-            raise ValueError("Not a Request-Line")
+        raise ValueError("Not a Request-Line")
 
     @classmethod
     def register(cls, method, uri, *responses, **config):
 
+        if "body" in config or "status" in config:
+            raise AttributeError("Did you mean `Entry.single_register(...)`?")
+
         default_config = dict(match_querystring=True, add_trailing_slash=True)
         default_config.update(config)
         config = default_config
@@ -240,5 +246,8 @@
         )
 
         cls.register(
-            method, uri, response, match_querystring=match_querystring,
+            method,
+            uri,
+            response,
+            match_querystring=match_querystring,
         )
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mocket-3.10.0/mocket/mockredis.py 
new/mocket-3.10.2/mocket/mockredis.py
--- old/mocket-3.10.0/mocket/mockredis.py       2021-03-20 19:51:56.000000000 
+0100
+++ new/mocket-3.10.2/mocket/mockredis.py       2021-12-01 19:25:53.000000000 
+0100
@@ -4,12 +4,12 @@
 from .mocket import Mocket, MocketEntry
 
 
-class Request(object):
+class Request:
     def __init__(self, data):
         self.data = data
 
 
-class Response(object):
+class Response:
     def __init__(self, data=None):
         self.data = Redisizer.redisize(data or OK)
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mocket-3.10.0/mocket/plugins/httpretty/__init__.py 
new/mocket-3.10.2/mocket/plugins/httpretty/__init__.py
--- old/mocket-3.10.0/mocket/plugins/httpretty/__init__.py      2021-08-31 
12:41:08.000000000 +0200
+++ new/mocket-3.10.2/mocket/plugins/httpretty/__init__.py      2021-12-01 
19:25:53.000000000 +0100
@@ -109,10 +109,9 @@
         if name == "last_request":
             last_request = getattr(Mocket, "last_request")()
             return last_request
-        elif name == "latest_requests":
+        if name == "latest_requests":
             return getattr(Mocket, "_requests")
-        else:
-            return getattr(Entry, name)
+        return getattr(Entry, name)
 
 
 HTTPretty = MocketHTTPretty()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mocket-3.10.0/mocket/utils.py 
new/mocket-3.10.2/mocket/utils.py
--- old/mocket-3.10.0/mocket/utils.py   2021-09-23 11:01:03.000000000 +0200
+++ new/mocket-3.10.2/mocket/utils.py   2021-12-01 19:25:53.000000000 +0100
@@ -41,5 +41,4 @@
 
     if decorator.__version__ < "5":
         return decorator.decorator(wrapper_)
-    else:
-        return decorator.decorator(wrapper_, kwsyntax=True)
+    return decorator.decorator(wrapper_, kwsyntax=True)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mocket-3.10.0/mocket.egg-info/PKG-INFO 
new/mocket-3.10.2/mocket.egg-info/PKG-INFO
--- old/mocket-3.10.0/mocket.egg-info/PKG-INFO  2021-09-23 11:06:41.000000000 
+0200
+++ new/mocket-3.10.2/mocket.egg-info/PKG-INFO  2021-12-01 19:58:33.000000000 
+0100
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: mocket
-Version: 3.10.0
+Version: 3.10.2
 Summary: Socket Mock Framework - for all kinds of socket animals, web-clients 
included -         with gevent/asyncio/SSL support
 Home-page: https://github.com/mindflayer/python-mocket
 Author: Giorgio Salluzzo
@@ -39,9 +39,6 @@
 .. image:: 
https://img.shields.io/lgtm/grade/python/g/mindflayer/python-mocket.svg?logo=lgtm&logoWidth=18
    :target: https://lgtm.com/projects/g/mindflayer/python-mocket/context:python
 
-.. image:: 
https://requires.io/github/mindflayer/python-mocket/requirements.svg?branch=master
-     :target: 
https://requires.io/github/mindflayer/python-mocket/requirements/?branch=master
-     :alt: Requirements Status
 
 A socket mock framework
 -------------------------
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/mocket-3.10.0/tests/main/test_http.py 
new/mocket-3.10.2/tests/main/test_http.py
--- old/mocket-3.10.0/tests/main/test_http.py   2021-03-20 19:51:56.000000000 
+0100
+++ new/mocket-3.10.2/tests/main/test_http.py   2021-12-01 19:57:28.000000000 
+0100
@@ -22,8 +22,8 @@
 
 class HttpTestCase(TestCase):
     def assertEqualHeaders(self, first, second, msg=None):
-        first = dict((k.lower(), v) for k, v in first.items())
-        second = dict((k.lower(), v) for k, v in second.items())
+        first = {k.lower(): v for k, v in first.items()}
+        second = {k.lower(): v for k, v in second.items()}
         self.assertEqual(first, second, msg)
 
 
@@ -382,3 +382,48 @@
         requests.get(url)
         requests.get(second_url)
         Mocket.assert_fail_if_entries_not_served()
+
+    @mocketize
+    def test_multi_register(self):
+        url = "http://foobar.com/path";
+        Entry.register(
+            Entry.POST,
+            url,
+            Response(body='{"foo":"bar0"}', status=200),
+            Response(body='{"foo":"bar1"}', status=201),
+            Response(body='{"foo":"bar2"}', status=202),
+        )
+
+        response = requests.post(url, json={"test": 0})
+        self.assertEqual(response.status_code, 200)
+        self.assertEqual(response.json(), {"foo": "bar0"})
+
+        response = requests.post(url, json={"test": 1})
+        self.assertEqual(response.status_code, 201)
+        self.assertEqual(response.json(), {"foo": "bar1"})
+
+        response = requests.post(url, json={"test": 2})
+        self.assertEqual(response.status_code, 202)
+        self.assertEqual(response.json(), {"foo": "bar2"})
+
+        response = requests.post(url, json={"test": 22})
+        self.assertEqual(response.status_code, 202)
+        self.assertEqual(response.json(), {"foo": "bar2"})
+
+    def test_suggestion_for_register_and_body(self):
+        url = "http://foobar.com/path";
+        with self.assertRaises(AttributeError):
+            Entry.register(
+                Entry.POST,
+                url,
+                body='{"foo":"bar0"}',
+            )
+
+    def test_suggestion_for_register_and_status(self):
+        url = "http://foobar.com/path";
+        with self.assertRaises(AttributeError):
+            Entry.register(
+                Entry.POST,
+                url,
+                status=201,
+            )

Reply via email to