Git Product home page Git Product logo

tavalidate's Introduction

tavalidate, utilities to help you validate Tavern response.

Installation

Tavalidate can be installed through pip.

pip install tavalidate

XML Validate

Tavern has great built-in Json support, but things are difficult when it comes to XML. Use tavalidate.xmlv package to validate XML response.

XML validation example:

response:
  status_code: 200
  verify_response_with:
    function: tavalidate:assert_xml
    extra_kwargs:
      expected: |
        <foo attr="!anystr">
          <bar attr2="baz">!anyint</bar>
        </foo>

Simply put, pass the expected xml as an argument to the tavalidate.xmlv.validate function. The function will validate the xml structure, node value and attribute value.

extra_kwargs

Below are the supported extra kwargs of tavalidate.xmlv.validate function.

expected

This is the expected XML string.

You may use some (not all) of the tavern magic values to match data of your specified type:

  • !anything: This matches value of any type.
  • !anystr: Matches any string
  • !anyint: Matches any integer
  • !anyfloat: Matches any float
  • !anybool: Matches any boolean

strict

Use strict: True if you want to make sure there's no extra tag in the response.

XML Save

Use tavalidate.xmlv package to save XML response.

It allows you to use XPath to specify the value to save inside the xml document. If the XPath somehow selects multiple nodes, tavalidate will print a warning, but the first value will still be saved.

XML save example:

response:
  save:
    $ext:
      function: tavalidate:save_xml
      extra_kwargs:
        variables:
          bar: '/foo/bar/text()'
          at1: '/foo/@at1'

Logging

Configure the logger tavalidate so you can see the response body and other logs in DEBUG level.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.