Skip to content

test: refactor Furl() as a plain function, curl(url), in `test/infamy/util.py #1157

@troglobit

Description

@troglobit

Alternative idea: add a plain function, curl(url), in test/infamy/util.py that does the meat of Furl::check().

Then the examples above would be:

    API = "http://example.com/api"
    if "success" in curl(API):
        print("API returned success")

    # Multiple needle check (all must match)
    response = curl(API)
    if all([n in response for n in ("user: alice", "status: active", "role: admin")]):
        print("All user details found")

    # Check from network namespace
    with IsolatedMacVlan("eth0") as ns:
        if "expected content" in ns.call(lambda: curl(API)):
            print("Content verified from namespace")

This is a bit more composable when the next type of HTTP check pops up. Also, having the logic of the check ("all must exist", in this case) in the test case makes it easier to see what is going on, at least to me.

Originally posted by @wkz in #1135 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesttestRegression test related

    Type

    No type

    Projects

    Status

    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions