Skip to main content

Send push notification from command line for single or multiple targets

Project description

PyMocky

Python package codecov

Mock server to return static response.

Install

pip install pymocky

Check with command:

pymocky -h

How to use

pymocky -p extras/sample/

Test with command (need curl):

curl http://localhost:9000/login

To change from default scenario to other use (server need be running):

pymocky --update-scenario "login-error"

Test again with command (need curl):

curl http://localhost:9000/login

Example of YAML file

mappings:
- id: hello_world
   scenario: login-success
   request:
      url: .*pymocky_hello_world.*
      method: post
      query_string: .*param1=value&param2=value2
      form_fields:
      username: .*demo
      password: .*12345
      headers:
         "Content-Type": "application/json"
      body: .*Hello World.*
   response:
      headers:
         "Content-Type": "application/json"
      body_raw: Hello world from pymocky!
      body_file: files/dummy.xml
      body_json:
         success: false
         data:
         errors: []
      body_image: images/image1.png
      body_python: files/dummy.py

You can use “body_raw”, “body_file”, “body_json”, “body_image” or “body_python” as response type.

body_raw: Raw text as response
body_file: File content with mimetype discovery by extension
body_json: Json as YAML object or string
body_image: Image file with mimetype discovery by extension
body_python: Python file to be executed

Change scenario

To change from default scenario to other use (server need be running):

pymocky --update-scenario "login-error"

Testing

You need install test dependencies with the command:

pip install -r requirements_tests.txt

To execute all tests use the command:

python -m pytest tests

To coverage test use the command:

python -m pytest --cov=. --cov-report=xml --cov-report=html tests

To install locally during development:

python setup.py install

Packaging

To package and upload for distribution on PyPi server use:

python setup.py upload

Contributing

  • Fork the project and clone locally.

  • Create a new branch for what you’re going to work on.

  • Push to your origin repository.

  • Create a new pull request in GitHub.

Buy me a coffee

Buy Me a Coffee at ko-fi.com

Supported By Jetbrains IntelliJ IDEA

Supported By Jetbrains IntelliJ IDEA

License

MIT

Copyright (c) 2020-present, Paulo Coutinho

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymocky-1.1.0-4.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

pymocky-1.1.0-4-py2.py3-none-any.whl (25.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pymocky-1.1.0-4.tar.gz.

File metadata

  • Download URL: pymocky-1.1.0-4.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.9.0

File hashes

Hashes for pymocky-1.1.0-4.tar.gz
Algorithm Hash digest
SHA256 95a4683f76dbcb88487696d44c14a4e6abe5b28c388c7399951c04898a583573
MD5 b3823ce2a15a417d02cf8f19f6bddc1c
BLAKE2b-256 b8d2c8fd2be89e2905cd39db8cbd18f52a9a2a8c88952e682720595fedd28287

See more details on using hashes here.

File details

Details for the file pymocky-1.1.0-4-py2.py3-none-any.whl.

File metadata

  • Download URL: pymocky-1.1.0-4-py2.py3-none-any.whl
  • Upload date:
  • Size: 25.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.9.0

File hashes

Hashes for pymocky-1.1.0-4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 6701c94b6103a2e786c45c60224bc2287ca9f045d59a868ee763bc5d88f0d52b
MD5 d836073f02670faef2fb039c9f02e30f
BLAKE2b-256 ac9bd1999d62683294167ab0939678be0ba96e52a100ed12e60b4463abd53ee2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page