How to use the schemathesis.models function in schemathesis

To help you get started, we’ve selected a few schemathesis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kiwicom / schemathesis / test / cli / output / test_default.py View on Github external
def test_display_statistic(capsys, swagger_20, endpoint):
    # Given multiple successful & failed checks in a single test
    success = models.Check("not_a_server_error", models.Status.success)
    failure = models.Check("not_a_server_error", models.Status.failure)
    single_test_statistic = models.TestResult(
        endpoint, [success, success, success, failure, failure, models.Check("different_check", models.Status.success)]
    )
    results = models.TestResultSet([single_test_statistic])
    # When test results are displayed
    default.display_statistic(results)

    lines = [line for line in capsys.readouterr().out.split("\n") if line]
    failed = click.style("FAILED", bold=True, fg="red")
    not_a_server_error = click.style("not_a_server_error", bold=True)
    different_check = click.style("different_check", bold=True)
    passed = click.style("PASSED", bold=True, fg="green")
    # Then all check results should be properly displayed with relevant colors
    assert lines[1:3] == [
        f"{not_a_server_error}            3 / 5 passed          {failed} ",
        f"{different_check}               1 / 1 passed          {passed} ",
github kiwicom / schemathesis / test / runner / test_checks.py View on Github external
def make_case(schema: BaseSchema, definition: Dict[str, Any]) -> models.Case:
    endpoint = models.Endpoint("/path", "GET", definition=definition, schema=schema)
    return models.Case(endpoint)
github kiwicom / schemathesis / test / cli / output / test_default.py View on Github external
def endpoint(swagger_20):
    return models.Endpoint("/success", "GET", definition={}, base_url="http://127.0.0.1:8080", schema=swagger_20)
github kiwicom / schemathesis / test / runner / test_checks.py View on Github external
def make_case(schema: BaseSchema, definition: Dict[str, Any]) -> models.Case:
    endpoint = models.Endpoint("/path", "GET", definition=definition, schema=schema)
    return models.Case(endpoint)