Skip to main content

Python Package GitHub contributors PyPI - Downloads PyPI - Downloads PyPI version fury.io PyPI pyversions GitHub tag PyPI - Format PyPI - Implementation Libraries.io dependency status for GitHub repo

kitty Mock Lib Python

A Python library for simulate an API with http and websocket request. In this 0.1.1.4 version of kitty-Mock-Lib-Python, allows you to simulate an API, being able to create routes in your own way, getting the history, details of it and other things you can do.

Installation

The latest stable version is available on PyPI. Either add kittymocklib_py to your requirements.txt file or install with pip:

pip install kittymocklib-py

Description

This project aims to help other types of projects that need a python API simulation and with this lib, you can simulate both http and websocket.

Starting

To run the project, you will need to install the following programs:

Steps

Step 0:

In this lib we use a docker image from kitty Mock, so for you to use it you will have to create a docker-compose.yml file in order to take advantage of this lib:

version: "3"
services:
  kittymock1:
    image: ntopus/kitty-mock:0.4.5
    ports:
      - "6999:6999"
      - "7000-7020:7000-7020"
    environment:
      SERVER_PORT: 6999
      MOCKER_PORTS_RANGE: 7000-7020

In order to run the docker, first you have to build and then upload the container.

docker-compose build 

Later:

docker-compose up

Or can run this way:

docker-compose up --build
          or
docker-compose up --build -d

examples of how to use:

How to use

First steps

Http route
  • Create the mocker

    from kittymocklib_py.mocker import Mocker
    
    def create_mocker():
        mocker = Mocker("http://localhost", 6999)
        print(f'My port: {mocker.mocker_port}')
    
  • Create http mock route

    from kittymocklib_py.mocker import Mocker
    
    def create_http_mock_route():
        mocker = Mocker("http://localhost", 6999)
        route = mocker.create_http_route("/hello", "GET", 200, "hello my friend")
    
  • Request http mock route

    from kittymocklib_py.mocker import Mocker
    
    def create_http_mock_route():
        mocker = Mocker("http://localhost", 6999)
        route = mocker.create_http_route("/hello", "GET", 200, "hello my friend")
        route_response = route.request()
    
  • Delete mocker server

    from kittymocklib_py.mocker import Mocker
    
    def create_http_mock_route():
        mocker = Mocker("http://localhost", 6999)
        response = mocker.delete()
    
  • Delete http mock route

    from kittymocklib_py.mocker import Mocker
    
    def create_http_mock_route():
        mocker = Mocker("http://localhost", 6999)
        route = mocker.create_http_route("/hello", "GET", 200, "hello my friend")
        route_response = route.delete()
    
  • Get history http mock route

    from kittymocklib_py.mocker import Mocker
    
    def create_http_mock_route():
        mocker = Mocker("http://localhost", 6999)
        route = mocker.create_http_route("/hello", "GET", 200, "hello my friend")
        route_response = route.get_history()
    
  • Clear history http mock route

    from kittymocklib_py.mocker import Mocker
    
    def create_http_mock_route():
        mocker = Mocker("http://localhost", 6999)
        route = mocker.create_http_route("/hello", "GET", 200, "hello my friend")
        route_response = route.clear_history()
    
  • Details http mock route

    from kittymocklib_py.mocker import Mocker
    
    def create_http_mock_route():
        mocker = Mocker("http://localhost", 6999)
        route = mocker.create_http_route("/hello", "GET", 200, "hello my friend")
        route_response = route.details()
    
WebSocket

Unavailable in this version

Test

In this lib, functional tests were used, with it we can run it like this:

python -m unittest discover tests -v

Additional

In this lib we use loggings, to be able to know everything that is going on behind the scenes, as well as to know if there was any error or bug somewhere in the code, it will demonstrate for you

Configuration

To execute the project, it is necessary to use VsCode or an IDE of your preference, so that it identifies the dependencies necessary for execution in the repository. Once the project is imported, it will be possible to test its functionality in real time.

Contributions

Contributions are always welcome! I hope I have helped someone in need.

🔓 License

MIT © Evandro Silva

Metadata

Release files for kittymocklib-py 0.1.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kittymocklib-py 0.1.1.4
File Size Uploaded Provenance Actions
kittymocklib_py-0.1.1.4.tar.gz 3.5 kB Without provenance Details for kittymocklib_py-0.1.1.4.tar.gz

Release files / kittymocklib_py-0.1.1.4.tar.gz

Download URL kittymocklib_py-0.1.1.4.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
3c9a230ba2ff8c8569221d01bf53d7701f8f7a89df436bf56fc00110f6c7f262
BLAKE2b-256 checksum
How to use checksums
9a37a836a89f13e45ee9d4fd70166edd491b9f71260d2a8bc67180ba930df418
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

Security for kittymocklib-py 0.1.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page