@@ -142,7 +142,9 @@ class Entry(MocketEntry):
142142 request_cls = Request
143143 response_cls = Response
144144
145- def __init__ (self , uri , method , responses , match_querystring = True ):
145+ default_config = {"match_querystring" : True }
146+
147+ def __init__ (self , uri , method , responses , match_querystring : bool = True ):
146148 uri = urlsplit (uri )
147149
148150 port = uri .port
@@ -151,7 +153,7 @@ def __init__(self, uri, method, responses, match_querystring=True):
151153
152154 super ().__init__ ((uri .hostname , port ), responses )
153155 self .schema = uri .scheme
154- self .path = uri .path
156+ self .path = uri .path or "/"
155157 self .query = uri .query
156158 self .method = method .upper ()
157159 self ._sent_data = b""
@@ -227,16 +229,15 @@ def register(cls, method, uri, *responses, **config):
227229 if "body" in config or "status" in config :
228230 raise AttributeError ("Did you mean `Entry.single_register(...)`?" )
229231
230- default_config = dict (match_querystring = True , add_trailing_slash = True )
231- default_config .update (config )
232- config = default_config
232+ if config .keys () - cls .default_config .keys ():
233+ raise KeyError (
234+ f"Invalid config keys: { config .keys () - cls .default_config .keys ()} "
235+ )
233236
234- if config [ "add_trailing_slash" ] and not urlsplit ( uri ). path :
235- uri += "/"
237+ _config = cls . default_config . copy ()
238+ _config . update ({ k : v for k , v in config . items () if k in _config })
236239
237- Mocket .register (
238- cls (uri , method , responses , match_querystring = config ["match_querystring" ])
239- )
240+ Mocket .register (cls (uri , method , responses , ** _config ))
240241
241242 @classmethod
242243 def single_register (
@@ -246,8 +247,9 @@ def single_register(
246247 body = "" ,
247248 status = 200 ,
248249 headers = None ,
249- match_querystring = True ,
250250 exception = None ,
251+ match_querystring = True ,
252+ ** config ,
251253 ):
252254 response = (
253255 exception
@@ -260,4 +262,5 @@ def single_register(
260262 uri ,
261263 response ,
262264 match_querystring = match_querystring ,
265+ ** config ,
263266 )
0 commit comments