Python module to make testing easier, it can generate random data like names and text, run commands, fetch urls, create files and directories, and more
MIT License
10
stars
0
forks
source link
testdata.create_server that will basically make a server that will return random info #90
Why even bother to define files? It would be cool to have an interface like this:
server = testdata.create_server()
with server:
r = testdata.fetch(server.url("foo.txt"))
print(r.content) # random text
r = testdata.fetch(server.url("/che/bar.jpg"))
print(r.content) # a jpg image
assert r.content == server.files["/che/bar.jpg"].read_bytes()
So basically, text files will return testdata.get_words() and any files with an image extension (eg, .jpg, .png) will return an image. Every file that is automatically generated will be placed into the Server's .files property so you can compare and make sure they were requested properly and stuff.
You could eventually make it even more dynamic where you can set query params to have it return certain things, so if you needed to check a 404:
r = testdata.fetch(server.url("/something?status_code=404"))
Why even bother to define files? It would be cool to have an interface like this:
So basically, text files will return
testdata.get_words()
and any files with an image extension (eg, .jpg, .png) will return an image. Every file that is automatically generated will be placed into the Server's.files
property so you can compare and make sure they were requested properly and stuff.You could eventually make it even more dynamic where you can set query params to have it return certain things, so if you needed to check a 404: