Skip to content

Commit 5e980b8

Browse files
authored
Merge pull request #31 from mocketize/mockhttp-entry-subclassing
Subclassing required to re-implement register methods.
2 parents 1348527 + 6efa345 commit 5e980b8

3 files changed

Lines changed: 19 additions & 19 deletions

File tree

mocket/mockhttp.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ def _parse_requestline(line):
118118
else:
119119
raise ValueError('Not a Request-Line')
120120

121-
@staticmethod
122-
def register(method, uri, *responses):
123-
Mocket.register(Entry(uri, method, responses))
121+
@classmethod
122+
def register(cls, method, uri, *responses):
123+
Mocket.register(cls(uri, method, responses))
124124

125-
@staticmethod
126-
def single_register(method, uri, body='', status=200, headers=None):
127-
Entry.register(method, uri, Response(body=body, status=status, headers=headers))
125+
@classmethod
126+
def single_register(cls, method, uri, body='', status=200, headers=None):
127+
cls.register(method, uri, Response(body=body, status=status, headers=headers))

mocket/mockredis.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ def __init__(self, addr, command, responses):
6060
def can_handle(self, data):
6161
return data.splitlines() == self.command
6262

63-
@staticmethod
64-
def register(addr, command, *responses):
65-
responses = [Entry.response_cls(r) for r in responses]
66-
Mocket.register(Entry(addr, command, responses))
67-
68-
@staticmethod
69-
def register_response(command, response, addr=None):
70-
Entry.register(addr, command, response)
71-
72-
@staticmethod
73-
def register_responses(command, responses, addr=None):
74-
Entry.register(addr, command, *responses)
63+
@classmethod
64+
def register(cls, addr, command, *responses):
65+
responses = [cls.response_cls(r) for r in responses]
66+
Mocket.register(cls(addr, command, responses))
67+
68+
@classmethod
69+
def register_response(cls, command, response, addr=None):
70+
cls.register(addr, command, response)
71+
72+
@classmethod
73+
def register_responses(cls, command, responses, addr=None):
74+
cls.register(addr, command, *responses)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
setup(
1919
name='mocket',
20-
version='1.3.3',
20+
version='1.3.4',
2121
author='Andrea de Marco, Giorgio Salluzzo',
2222
author_email='24erre@gmail.com, giorgio.salluzzo@gmail.com',
2323
url='https://github.com/mocketize/python-mocket',

0 commit comments

Comments
 (0)