tomashanacek / mock-server Goto Github PK
View Code? Open in Web Editor NEWSimple mock server for REST API
Home Page: http://tomashanacek.github.com/mock-server/
License: Other
Simple mock server for REST API
Home Page: http://tomashanacek.github.com/mock-server/
License: Other
It would be super cool if I could capture requests made by my app to some API server and save them as mocks.
Rationale behind this would be that developer could catch some specific production communication and reproduce it locally..
This could be done with simple proxy server.
Hi,
When i use this great tool with tornado4.3(in python 2.6.6 on centos 6.5), I meet an error shown below(with my request).
[I 160121 21:26:00 web:1946] 200 POST /__manage/create (192.168.23.1) 3.62ms
[E 160121 21:26:00 web:1524] Uncaught exception GET /__manage (192.168.23.1)
HTTPServerRequest(protocol='http', host='192.168.23.140:8888', method='GET', uri='/__manage', version='HTTP/1.0', remote_ip='192.168.23.1', headers={'Accept-Language': 'zh-CN,zh;q=0.8', 'Accept-Encoding': 'gzip, deflate, sdch', 'Host': '192.168.23.140:8888', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'Upgrade-Insecure-Requests': '1', 'Dnt': '1', 'Connection': 'close', 'Referer': 'http://192.168.23.140:8888/__manage/create', 'Pragma': 'no-cache', 'Cache-Control': 'no-cache', 'Cookie': '_xsrf=2|2637eead|1c4ae088fc8d56a6903bb137e8f6a3b0|1453364329; flash_msg_success="2|1:0|10:1453382760|17:flash_msg_success|68:UmVzb3VyY2UgJ3Rlc3RfYXBpJyBoYXMgYmVlbiBzdWNjZXNzZnVsbHkgY3JlYXRlZC4=|c4146521abbb980c079a20ee2ad9288d7b7d8bd8b44dd431bf4d8732edac6e7f"', 'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36'})
Traceback (most recent call last):
File "/home/winkidney/.virtualenvs/mock/lib/python2.6/site-packages/tornado/web.py", line 1443, in _execute
result = method(*self.path_args, **self.path_kwargs)
File "/home/winkidney/workspace/mock-server/mock_server/handlers.py", line 407, in get
("success", "error")))
File "/home/winkidney/.virtualenvs/mock/lib/python2.6/site-packages/tornado/web.py", line 699, in render
html = self.render_string(template_name, **kwargs)
File "/home/winkidney/.virtualenvs/mock/lib/python2.6/site-packages/tornado/web.py", line 806, in render_string
return t.generate(**namespace)
File "/home/winkidney/.virtualenvs/mock/lib/python2.6/site-packages/tornado/template.py", line 345, in generate
return execute()
File "list_resources_html.generated.py", line 48, in _tt_execute
if request.headers.has_key('X-Scheme') and request.headers['X-Scheme']: # list_resources.html:10 (via layout.html:55)
AttributeError: 'HTTPHeaders' object has no attribute 'has_key'
[E 160121 21:26:00 web:1946] 500 GET /__manage (192.168.23.1) 41.66ms
I will add a Pull request for it(safely get the header's value for tornado 4.3).
Returning 500 on creating a new resource and browsing resources.
Mock-server looks awesome. would you expect this to work on a windows machine?
I'm having trouble installing bcrypt.
Traceback (most recent call last):
File "/usr/lib64/python2.7/site-packages/tornado/web.py", line 1332, in _execute
result = method(_self.path_args, *_self.path_kwargs)
File "/usr/lib64/python2.7/site-packages/tornado/web.py", line 2601, in wrapper
return method(self, _args, *_kwargs)
File "/usr/lib/python2.7/site-packages/mock_server/handlers.py", line 464, in get
jsonrpc=jsonrpc_available)
File "/usr/lib64/python2.7/site-packages/tornado/web.py", line 665, in render
html = self.render_string(template_name, **kwargs)
File "/usr/lib64/python2.7/site-packages/tornado/web.py", line 772, in render_string
return t.generate(**namespace)
File "/usr/lib64/python2.7/site-packages/tornado/template.py", line 278, in generate
return execute()
File "create_resource_html.generated.py", line 47, in _tt_execute
if flash_messages: # create_resource.html:16 (via layout.html:55)
NameError: global name 'flash_messages' is not defined
root@ubuntu:~/rest# easy_install mock-server
Searching for mock-server
Reading https://pypi.python.org/simple/mock-server/
Download error on https://pypi.python.org/simple/mock-server/: [Errno 1] _ssl.c:510: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed -- Some packages may not be found!
Couldn't find index page for 'mock-server' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.python.org/simple/
Download error on https://pypi.python.org/simple/: [Errno 1] _ssl.c:510: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed -- Some packages may not be found!
No local packages or download links found for mock-server
error: Could not find suitable distribution for Requirement.parse('mock-server')
I am running in python 3.7. Encountering the following error when trying to create an endpoint
Uncaught exception GET /__manage (::1)
HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/__manage', version='HTTP/1.1', remote_ip='::1', headers={'Host': 'localhost:8888', 'Connection': 'keep-alive', 'Upgrade-Insecure-Requests': '1', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36', 'Sec-Fetch-Dest': 'document', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', 'Sec-Fetch-Site': 'same-origin', 'Sec-Fetch-Mode': 'navigate', 'Sec-Fetch-User': '?1', 'Referer': 'http://localhost:8888/__manage/create?url_path=&method=GET&status_code=200&format=json', 'Accept-Encoding': 'gzip, deflate, br', 'Accept-Language': 'en-US,en;q=0.9', 'Cookie': 'csrftoken=MWWmqR1DGiHkAML7zrz1n0eoVdnlEkELXnj2PsqgbxxCZOlNCvbxzwSx3E0YGt0T; Pastease.passive.chance.kfzz9br7dC3Qwzl=1; Pastease.passive.activated.kfzz9br7dC3Qwzl=0; _ga=GA1.1.1041436616.1576026813; _xsrf=2|850e85be|11696f0fd78a46e6d9b1483a4522d35e|1583298649'})
Traceback (most recent call last):
File "/Users/corinel/.local/share/virtualenvs/trade-analysis-api-MP67PEe1/lib/python3.7/site-packages/tornado/web.py", line 1443, in _execute
result = method(*self.path_args, **self.path_kwargs)
File "/Users/corinel/.local/share/virtualenvs/trade-analysis-api-MP67PEe1/lib/python3.7/site-packages/mock_server/handlers.py", line 372, in get
paths = resources_loader.load()
File "/Users/corinel/.local/share/virtualenvs/trade-analysis-api-MP67PEe1/lib/python3.7/site-packages/mock_server/methodslisting.py", line 34, in load
for item in os.walk(self.api_dir)
File "/Users/corinel/.local/share/virtualenvs/trade-analysis-api-MP67PEe1/lib/python3.7/site-packages/mock_server/methodslisting.py", line 35, in <listcomp>
if self._check_folder(item)]
File "/Users/corinel/.local/share/virtualenvs/trade-analysis-api-MP67PEe1/lib/python3.7/site-packages/mock_server/methodslisting.py", line 55, in _complete_path
url_path = UrlPath(get_url_path(item[0][len(self.api_dir):]))
File "/Users/corinel/.local/share/virtualenvs/trade-analysis-api-MP67PEe1/lib/python3.7/site-packages/mock_server/methodslisting.py", line 107, in __init__
self.id = slugify(self.path)
File "/Users/corinel/.local/share/virtualenvs/trade-analysis-api-MP67PEe1/lib/python3.7/site-packages/mock_server/util.py", line 47, in slugify
slug = unicodedata.normalize("NFKD", unicode(value)).encode("ascii", "ignore")
NameError: name 'unicode' is not defined
Python 3 renamed the unicode
type to str
, the old str
type has been replaced by bytes
Such as I will send a post request, which content like following
listDatadata1The response data is different if the input parameter data changed from "data1" to "data2" . In this case, it needs write some python codes to implement it. Is there any program interface?
It would be nice to be able to handle some basic query string parameters to allow for mocked filtering (for example).
Say I've got 50 users. To get all users, I could hit /user
. But if I only want admin users, I might want to hit /user?is_admin=1
or some such. It doesn't appear that this is currently possible based on a quick glance through some code and the tests.
Perhaps it could search for files that follow a pattern like user/GET_200_q_is_admin=1.json (possibly sorting the query string parameters alphabetically to avoid redundancy).
need support custom status code like 6xx
[E 161020 15:31:56 web:1548] Uncaught exception GET /__manage (172.16.3.71)
HTTPServerRequest(protocol='http', host='172.16.58.3:8888', method='GET', uri='/__manage', version='HTTP/1.1', remote_ip='172.16.3.71', headers={'Accept-Language': 'zh-CN,zh;q=0.8,en;q=0.6,zh-TW;q=0.4', 'Accept-Encoding': 'gzip, deflate, sdch', 'Host': '172.16.58.3:8888', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8', 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36', 'Connection': 'keep-alive', 'Referer': 'http://172.16.58.3:8888/__manage/create', 'Cookie': '_xsrf=2|04285626|e45865c15b4d35b361ab2ce6e758cc5f|1476943443; user="2|1:0|10:1476948406|4:user|20:L21vY2svcHl0aG9uLw==|9e277fa4d47d5c84aeb713fc1a7fbc0c521335b89b1bf96d46ddce6498572c74"', 'Upgrade-Insecure-Requests': '1'})
Traceback (most recent call last):
File "/usr/lib64/python2.6/site-packages/tornado/web.py", line 1467, in _execute
result = method(_self.path_args, *_self.path_kwargs)
File "/usr/lib/python2.6/site-packages/mock_server/handlers.py", line 407, in get
("success", "error")))
File "/usr/lib64/python2.6/site-packages/tornado/web.py", line 719, in render
html = self.render_string(template_name, **kwargs)
File "/usr/lib64/python2.6/site-packages/tornado/web.py", line 826, in render_string
return t.generate(**namespace)
File "/usr/lib64/python2.6/site-packages/tornado/template.py", line 348, in generate
return execute()
File "list_resources_html.generated.py", line 48, in _tt_execute
if request.headers.has_key('X-Scheme') and request.headers['X-Scheme']: # list_resources.html:10 (via layout.html:55)
AttributeError: 'HTTPHeaders' object has no attribute 'has_key'
[E 161020 15:31:56 web:1971] 500 GET /__manage (172.16.3.71) 68.52ms
I can't access the service from my own IP, but 127.0.0.1 works
can you tell me why and help me out?
when i start with :
mock-server --address=119.254.100.35 --dir=/root/mockServer
it occours:
Traceback (most recent call last):
File "/usr/local/bin/mock-server", line 66, in
main()
File "/usr/local/bin/mock-server", line 60, in main
server.bind(options.port, options.address)
File "/usr/local/lib/python2.7/site-packages/tornado/tcpserver.py", line 170, in bind
backlog=backlog)
File "/usr/local/lib/python2.7/site-packages/tornado/netutil.py", line 145, in bind_sockets
sock.bind(sockaddr)
File "/usr/local/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 99] Cannot assign requested address
Hi.
Creating a mock server from scratch with a test method which should return HTML doesn't seem to work. The files are created but the server keeps saying the method doesn't exist when performing a request with a web browser. Here are the contents of the server files:
application.json:
{"resources": {"GET-test": {"category": ""}}}
test/GET_200.html:
<html><body>Hi</body></html>
test/GET_H_200.html empty.
access log:
{"status": 200, "headers": {"Accept-Language": "es-es", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/600.3.18 (KHTML, like Gecko) Version/7.1.3 Safari/537.85.12", "Host": "localhost:8888", "Cookie": "_xsrf=2|bf7b90b8|9517b3acf74d9614bd0baeb4690f7ac7|1425469503"}, "remote_ip": "::1", "time": "2015-03-12T10:19:43.243750", "request_time": 1.837015151977539, "response": {"body": "Api does't exists, <a href=\"/__manage/create?url_path=&method=GET&status_code=200&format=json\">create resource method</a>", "headers": [["Content-Type", "text/html"], ["Access-Control-Allow-Origin", "*"]], "status_code": 404}, "url_path": "/", "body": "", "method": "GET", "uri": "/"}
{"status": 200, "headers": {"Accept-Language": "es-es", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/600.3.18 (KHTML, like Gecko) Version/7.1.3 Safari/537.85.12", "Host": "localhost:8888", "Cookie": "_xsrf=2|bf7b90b8|9517b3acf74d9614bd0baeb4690f7ac7|1425469503", "If-None-Match": "\"bf21a9e8fbc5a3846fb05b4fa0859e0917b2202f\""}, "remote_ip": "::1", "time": "2015-03-12T10:20:04.500854", "request_time": 0.7579326629638672, "response": {"body": "Api does't exists, <a href=\"/__manage/create?url_path=test&method=GET&status_code=200&format=json\">create resource method</a>", "headers": [["Content-Type", "text/html"], ["Access-Control-Allow-Origin", "*"]], "status_code": 404}, "url_path": "/test", "body": "", "method": "GET", "uri": "/test"}
{"status": 200, "headers": {"Accept-Language": "es-es", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/600.3.18 (KHTML, like Gecko) Version/7.1.3 Safari/537.85.12", "Host": "localhost:8888", "Cookie": "_xsrf=2|bf7b90b8|9517b3acf74d9614bd0baeb4690f7ac7|1425469503"}, "remote_ip": "::1", "time": "2015-03-12T10:20:04.680572", "request_time": 0.5021095275878906, "response": {"body": "Api does't exists, <a href=\"/__manage/create?url_path=test&method=GET&status_code=200&format=json\">create resource method</a>", "headers": [["Content-Type", "text/html"], ["Access-Control-Allow-Origin", "*"]], "status_code": 404}, "url_path": "/test", "body": "", "method": "GET", "uri": "/test"}
It seems that creating a json response with the HTML works, but then clients don't interpret the result as HTML.
There's a web service I'm trying to hit via the Mock Server Proxy
that requires a specific SSL client certificate (else it just doesn't answer requests and they timeout). I brief testing it appears that the SSL client certificate that I have setup might not be being sent along to the service. I didn't see any documentation indicating specifically if this is supported, however it did seem that the SSL CONNECT
method should pass the client certificate along to the service (based on my somewhat limited understanding of this method). I believe in my testing I was using this method as I connect to the proxy over SSL and had to turn off server certificate validation (because I didn't want to mess with trusting the proxy CA). Please advise. Thanks!
[W 140825 16:46:09 web:1404] 403 POST /__manage/create (::1): XSRF cookie does not match POST argument
[W 140825 16:46:09 web:1811] 403 POST /__manage/create (::1) 0.83ms
Whenever you DELETE a resource there should be an option to actually delete it from the filesystem.
Whenever you create a resource it will be created on the filesystem.
You see where this is going.
Uncaught exception GET /__manage (172.16.3.71)
HTTPServerRequest(protocol='http', host='172.16.58.3:8888', method='GET', uri='/__manage', version='HTTP/1.1', remote_ip='172.16.3.71', headers={'Accept-Language': 'zh-CN,zh;q=0.8,en;q=0.6,zh-TW;q=0.4', 'Accept-Encoding': 'gzip, deflate, sdch', 'Host': '172.16.58.3:8888', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8', 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36', 'Connection': 'keep-alive', 'Referer': 'http://172.16.58.3:8888/__manage/create', 'Cookie': '_xsrf=2|04285626|e45865c15b4d35b361ab2ce6e758cc5f|1476943443; user="2|1:0|10:1476946569|4:user|20:L21vY2svcHl0aG9uLw==|2842e00ba11282519f13ad03ed5d94ee60c09acf46813ffa18bd6020e46ba163"', 'Upgrade-Insecure-Requests': '1'})
Traceback (most recent call last):
File "/usr/lib64/python2.6/site-packages/tornado/web.py", line 1467, in _execute
result = method(_self.path_args, *_self.path_kwargs)
File "/usr/lib/python2.6/site-packages/mock_server/handlers.py", line 407, in get
("success", "error")))
File "/usr/lib64/python2.6/site-packages/tornado/web.py", line 719, in render
html = self.render_string(template_name, **kwargs)
File "/usr/lib64/python2.6/site-packages/tornado/web.py", line 826, in render_string
return t.generate(**namespace)
File "/usr/lib64/python2.6/site-packages/tornado/template.py", line 348, in generate
return execute()
File "list_resources_html.generated.py", line 48, in _tt_execute
if request.headers.has_key('X-Scheme') and request.headers['X-Scheme']: # list_resources.html:10 (via layout.html:55)
AttributeError: 'HTTPHeaders' object has no attribute 'has_key'
[E 161020 14:56:41 web:1971] 500 GET /__manage (172.16.3.71) 9.75ms
I just ran into an issue where mock-server raises an exception if http headers are passed. See the exception below where I've set an HTTP header called `myheader``.
HTTPServerRequest(protocol='http', host='localhost:8888', method='POST', uri='/foo/bar', version='HTTP/1.1', remote_ip='::1', headers={'Content-Length': '296', 'Accept-Encoding': 'gzip, deflate', 'Http_myheader': 'foo123', 'Host': 'localhost:8888', 'Accept': '*/*', 'User-Agent': 'python-requests/2.8.1', 'Connection': 'keep-alive', 'Content-Type': 'application/json'})
Traceback (most recent call last):
File "/usr/lib64/python2.7/site-packages/tornado/web.py", line 1401, in _stack_context_handle_exception
raise_exc_info((type, value, traceback))
File "/usr/lib64/python2.7/site-packages/tornado/web.py", line 1603, in wrapper
result = method(self, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/mock_server/handlers.py", line 123, in post
self._resolve_request(path, format)
File "/usr/lib/python2.7/site-packages/mock_server/handlers.py", line 213, in _resolve_request
self.log_request(response)
File "/usr/lib/python2.7/site-packages/mock_server/handlers.py", line 74, in log_request
model.add_to_resources_log(self.log_request_name, data)
File "/usr/lib/python2.7/site-packages/mock_server/model.py", line 379, in add_to_resources_log
f.write("%s\n" % json.dumps(data, cls=ExtendedJSONEncoder))
File "/usr/lib64/python2.7/json/__init__.py", line 250, in dumps
sort_keys=sort_keys, **kw).encode(obj)
File "/usr/lib64/python2.7/json/encoder.py", line 207, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib64/python2.7/json/encoder.py", line 270, in iterencode
return _iterencode(o, 0)
File "/usr/lib/python2.7/site-packages/mock_server/util.py", line 38, in default
return json.JSONEncoder.default(self, obj)
File "/usr/lib64/python2.7/json/encoder.py", line 184, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <tornado.httputil.HTTPHeaders object at 0x2482bd0> is not JSON serializable
I was able to pinpoint that this issue to tornado 4.3. This issue does not occur in tornado versions 4.2 or below. I think the fix is as straightforward as fixing tornado<4.3, >=3.1
in requirements.txt
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tornado/web.py", line 1443, in _execute
result = method(*self.path_args, **self.path_kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mock_server/handlers.py", line 372, in get
paths = resources_loader.load()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mock_server/methodslisting.py", line 34, in load
for item in os.walk(self.api_dir)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mock_server/methodslisting.py", line 35, in
if self._check_folder(item)]
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mock_server/methodslisting.py", line 55, in _complete_path
url_path = UrlPath(get_url_path(item[0][len(self.api_dir):]))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mock_server/methodslisting.py", line 107, in init
self.id = slugify(self.path)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mock_server/util.py", line 47, in slugify
slug = unicodedata.normalize("NFKD", unicode(value)).encode("ascii", "ignore")
NameError: name 'unicode' is not defined
Are there any plans on supporting Python 3?
Thanks!
when trying to install with python v3.9.14, a transitive dependency conflict arrises between py-bcrypt
and futures
over the versions of the metadata
package.
Collecting tornado==4.3
Downloading tornado-4.3.tar.gz (450 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 450.9/450.9 KB 6.8 MB/s eta 0:00:00
Preparing metadata (setup.py) ... done
Collecting markdown2>=2.1.0
Downloading markdown2-2.4.6-py2.py3-none-any.whl (37 kB)
Collecting py-bcrypt>=0.3
Downloading py-bcrypt-0.4.tar.gz (27 kB)
Preparing metadata (setup.py) ... done
Collecting futures>=2.1.3
Downloading futures-3.0.5.tar.gz (25 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [25 lines of output]
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 14, in <module>
File "/Users/withtwoemms/.pyenv/versions/mock-server/lib/python3.9/site-packages/setuptools/__init__.py", line 18, in <module>
from setuptools.dist import Distribution
File "/Users/withtwoemms/.pyenv/versions/mock-server/lib/python3.9/site-packages/setuptools/dist.py", line 32, in <module>
from setuptools.extern.more_itertools import unique_everseen
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
File "<frozen importlib._bootstrap>", line 565, in module_from_spec
File "/Users/withtwoemms/.pyenv/versions/mock-server/lib/python3.9/site-packages/setuptools/extern/__init__.py", line 52, in create_module
return self.load_module(spec.name)
File "/Users/withtwoemms/.pyenv/versions/mock-server/lib/python3.9/site-packages/setuptools/extern/__init__.py", line 37, in load_module
__import__(extant)
File "/Users/withtwoemms/.pyenv/versions/mock-server/lib/python3.9/site-packages/setuptools/_vendor/more_itertools/__init__.py", line 1, in <module>
from .more import * # noqa
File "/Users/withtwoemms/.pyenv/versions/mock-server/lib/python3.9/site-packages/setuptools/_vendor/more_itertools/more.py", line 5, in <module>
from concurrent.futures import ThreadPoolExecutor
File "/private/var/folders/85/t66vqlvs15n3vk9441vsw74w0000gr/T/pip-install-in_dzwj0/futures_2107073ab68246ba84c2c2e934dfd990/concurrent/futures/__init__.py", line 8, in <module>
from concurrent.futures._base import (FIRST_COMPLETED,
File "/private/var/folders/85/t66vqlvs15n3vk9441vsw74w0000gr/T/pip-install-in_dzwj0/futures_2107073ab68246ba84c2c2e934dfd990/concurrent/futures/_base.py", line 357
raise type(self._exception), self._exception, self._traceback
^
SyntaxError: invalid syntax
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
When I click Add Request the server shows nothing in the log and nothing happens. This is unlike the demo site which works. I've specified "--debug" but don't get any additional errors.
To setup mock-server I'm doing the following:
virtualenv venv
10258 source venv/bin/activate
10259 pip install -r requirements.txt
10260 python setup.py build
10261 python setup.py install
10262 mock-server --dir=mock_server/example
When I install mock-server from scratch and than call the server from my browser I get the following message:
"Api does't exists, create resource method"
There's an 'n' missing in the word doesn't.
Hi ,
I believe this mock server has got a lot of potential, I am finding it very useful in testing basic rest calls. I am not able to have a PUT request configured which can accept a file. Getting following error trace:
[E 150204 16:59:19 web:1421] Uncaught exception PUT /xyz/Test%20Company/abcd?rev=173-0554db5b52e7881d09991afd04bab7f2 (9.xxx.xxx.xxx)
HTTPServerRequest(protocol='http', host='9.xxx.xxx.xxx:8888', method='PUT', uri='/usb/Test%20Company/abcd?rev=173-0554db5b52e7881d09991afd04bab7f2', version='HTTP/1.1', remote_ip='9.xxx.xxx.xxx', headers={'Connection': 'Keep-Alive', 'Accept-Encoding': 'gzip,deflate', 'Transfer-Encoding': 'chunked', 'Content-Type': 'text/plain', 'Host': '9.xxx.xxx.xxx:8888', 'User-Agent': 'Apache-HttpClient/4.3 (java 1.5)'})
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/tornado-4.1b2-py2.6-linux-x86_64.egg/tornado/web.py", line 1302, in _stack_context_handle_exception
raise_exc_info((type, value, traceback))
File "/usr/lib/python2.6/site-packages/tornado-4.1b2-py2.6-linux-x86_64.egg/tornado/web.py", line 1489, in wrapper
result = method(self, _args, *_kwargs)
File "/usr/lib/python2.6/site-packages/mock_server-0.3.7-py2.6.egg/mock_server/handlers.py", line 135, in put
self._resolve_request(path, format)
File "/usr/lib/python2.6/site-packages/mock_server-0.3.7-py2.6.egg/mock_server/handlers.py", line 213, in _resolve_request
self.log_request(response)
File "/usr/lib/python2.6/site-packages/mock_server-0.3.7-py2.6.egg/mock_server/handlers.py", line 67, in log_request
"body": unicode(self.request.body),
UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 183: ordinal not in range(128)
[E 150204 16:59:19 web:1825] 500 PUT /xyz/Test%20Company/abcd?rev=173-0554db5b52e7881d09991afd04bab7f2
It would be great if there was a way to accept the file.
Thanks,
Hey,
I have a development dependency, i.e. six >=1.11.0
, but mock-server
has a hard dependency on six ==1.10.0
. Is it possible to relax that to six >=1.10.0
?
Best regards
Is there a way for the route to respond with a certain response code without needing to add a url parameter to induce the response code?
For example, if I have a route called /session, and I want to get a 200 response then I call base_url/session and if I have everything setup correctly I get a 200 response.
However, if I call the same route but want to get a 201 response instead, it seems that I am forced to call base_url/session?__statusCode=201
For my specific test case I can't change the url params on the fly so I'd prefer to have my client try to access the same route with the same params every time and be able to manipulate the server response rather than needing to induce a certain server response using params.
Does that make sense? Is it possible that this tool can be used in the way I've described?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.