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.1.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 2 Python 3

File details

Details for the file pymocky-1.1.1.tar.gz.

File metadata

  • Download URL: pymocky-1.1.1.tar.gz
  • Upload date:
  • Size: 14.9 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.1.tar.gz
Algorithm Hash digest
SHA256 414a00e593c2c34e567a1f388f4bdfa6ac9ed0a1f61f293413e3b5627221cfd3
MD5 3eeaaf5cd7040128500c6d8f9ae13d44
BLAKE2b-256 eeaf91764b0ebb4a72d469357b913720258019bdadf22aabf670dd0607be9c61

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pymocky-1.1.1-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.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 6480488c74b104875eed27e8c3291d9561f4d3df0b2af2c3e4bf383f1e21fd82
MD5 073ae3c1f76c440695a5628be5dd128b
BLAKE2b-256 b850f56770cbf6bf44ec24c9a1a17cbd2ec65622d351fda3a2b64d43653962d0

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