Skip to content

testdata.create_server that will basically make a server that will return random info #90

Description

@Jaymon

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"))

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions