Git Product home page Git Product logo

mock-request-api's Introduction

mock-request

CircleCI codecov

Mock API requests with and obtain a pre-saved response object.

With this package you can mock the behavior of the requests library. You can write code that looks identical to the one you'd be using in an actual request, but which in reality loads pre-saved response objects with matching request parameters.

Requirements

  • pandas>=0.23.0
  • requests>=2.21.0

Installation

This package is not yet available in PyPy, but you can still install it using pip. First clone the repo, navigate into the repo directory, and then issue

$ pip install mock_request --user

in your terminal.

Usage

Until a more complete of examples is available, you can get a good sense of how to use this package by working through the mock-request/tests/files/yelp-api-request.ipynb notebook.

History

This package was originally created for online courses, where it became necessary for several reasons:

  1. hitting an API thousands of time a day from the same IP and/or with the same authentication will hit the daily download limit
  2. the online course will not rely on the API servers, and will continue to work even if they're down or if the API changes
  3. it shortens the execution time of online exercises

However, this package can be used for more generic situations. One good example would be to write unit tests for code performing API requests but without actually executing the requests.

Contributing

I'll be happy (and proud!) if you'd like to contribute to this package. Feel free to open an issue explaining the fix/improvement/expansion you'd like to develop and let's discuss it.

mock-request-api's People

Contributors

adrian-soto avatar adrian-datacamp avatar leehach avatar

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.