Skip to main content

Object-Oriented HTTP Request

Project description

winney

pypi Codacy Badge

Install

pip install winney

Tutorial

from winney.winney import Address
from winney import Winney, retry
from winney.mock import Mock


class UserMock(Mock):
    data = {"name": "olivetree"}


class UserCenter(object):
    def __init__(self):
        self.winney = Winney(host="localhost", port=5000)
        self.init_functions()

    def init_functions(self):
        self.winney.register(method="post",
                             name="login",
                             uri="/api/login",
                             mock=False,
                             mock_data=None)
        self.winney.register(method="get",
                             name="get_user",
                             uri="/api/user",
                             mock=True,
                             mock_data=UserMock())

    def login(self, account, password):
        r = self.winney.login(json={"account": account, "password": password})
        return r.json()

    def get_user(self, user_id):
        r = self.winney.get_user(data={"user_id": user_id})
        return r.json()


if __name__ == "__main__":
    uc = UserCenter()
    uc.login("hello", "123456")

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

winney-0.5.6.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

winney-0.5.6-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file winney-0.5.6.tar.gz.

File metadata

  • Download URL: winney-0.5.6.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.9

File hashes

Hashes for winney-0.5.6.tar.gz
Algorithm Hash digest
SHA256 53f7f7995b312ca6266ebf5862acaaba440e1180be77ffcadeba1c8bbadecdab
MD5 e01297e0ec6cde3cc424bcde13468372
BLAKE2b-256 59b591bcf08e7cf538cf39c9f9df528cbb6a83002b14a577d686f59864a5e6be

See more details on using hashes here.

File details

Details for the file winney-0.5.6-py3-none-any.whl.

File metadata

  • Download URL: winney-0.5.6-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for winney-0.5.6-py3-none-any.whl
Algorithm Hash digest
SHA256 788e1bafe9d200024e6b6bb3c45ea3a29b68614ff2177587a1e5fdd22f374d39
MD5 18a19bc9b2f7fe018f76712478bd09bb
BLAKE2b-256 81c9b9dc07ac915dd414968340511bed4baefcda8bf257cc49584af854a1f36b

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