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
      sys_path: ["auto"]

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

When you use “body_python” you can add array “sys_path” and pymocky will add these paths to “sys.path” list. The list of “sys.path” is reloaded to original (when pymocky start is stored a copy of this list) everytime that YAML files are parsed again. When you use “auto” in the array, the path will be the directory of python file to be execute.

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

or:

pip install -e .

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

Uploaded Source

Built Distribution

pymocky-1.2.0-1-py2.py3-none-any.whl (9.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pymocky-1.2.0-1.tar.gz.

File metadata

  • Download URL: pymocky-1.2.0-1.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for pymocky-1.2.0-1.tar.gz
Algorithm Hash digest
SHA256 3451f50690ea93653270977861d614159f8d964741aba2f6d6ad29522b2a218b
MD5 97f04816b2d6ad71259e223beb8d8895
BLAKE2b-256 df61ef1f218f54021979a20af50b8c9393ebbc52b3b6cf46a12fcac99da21852

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pymocky-1.2.0-1-py2.py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for pymocky-1.2.0-1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 4a15b9c601d87d898fdd98672c95bcaf2fca1ba5b07d0a6c5b7972c4d8805926
MD5 3cd347e96881551ad250fdce88267f69
BLAKE2b-256 60713e7e4eb3fecc3f72cbdb0f9a2ac543bda664f068a07689090088acd9387a

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